欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JSP 中文传到 Spring MVC controller 乱码问题

程序员文章站 2022-04-11 09:41:37
...

jsp页面编码设置 <%@ page pageEncoding="UTF-8"%>

 

修改web.xml,增加编码过滤器

<filter>    
    <filter-name>characterEncodingFilter</filter-name>    
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>    
    <init-param>    
        <param-name>encoding</param-name>    
        <param-value>UTF-8</param-value>    
    </init-param>    
    <init-param>    
        <param-name>forceEncoding</param-name>    
        <param-value>true</param-value>    
    </init-param>    
</filter>    
<filter-mapping>    
    <filter-name>characterEncodingFilter</filter-name>    
    <url-pattern>/*</url-pattern>    
</filter-mapping>

 

相关标签: springMvc 乱码