SpringMVC入门篇(五)POST中文乱码解决
2017-06-13 08:56
239 查看
SpringMVC框架提供了的解决POST提交中文乱码的问题,在web.xml加入如下代码即可:
对于get请求中文参数出现乱码解决方法有两个:
1、修改tomcat配置文件添加编码与工程编码一致。
2、对参数进行重新编码。
ISO8859-1是tomcat默认编码,需要将tomcat编码后的内容按utf-8编码
<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> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
对于get请求中文参数出现乱码解决方法有两个:
1、修改tomcat配置文件添加编码与工程编码一致。
<Connector URIEncoding="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
2、对参数进行重新编码。
String userName new String(request.getParamter("userName").getBytes("ISO8859-1"),"utf-8")
ISO8859-1是tomcat默认编码,需要将tomcat编码后的内容按utf-8编码
相关文章推荐
- SpringMVC第六篇——解决中文乱码(POST/GET提交)
- 解决问题:在使用springmvc的web.xml配置乱码拦截器之后接收的get或者post请求中文还是乱码
- 解决springmvc的get提交和post提交的中文乱码问题
- 解决springMVC POST 中文乱码
- springMVC解决post、get中文乱码
- springmvc解决post中文乱码
- 解决SpringMvc限定请求方法POST推送数据出现的中文乱码问题
- JQuery中Ajax的Post提交中文乱码、windows.location.href 中文汉字乱码和springmvc使用原生态HttpServletRequest接收参数中文乱码解决办法
- springmvc解决post中文乱码问题
- get/post时中文乱码问题的解决办法(转载)
- Post与Get提交使用过滤器解决中文乱码问题
- C# webconfig配置解决post 传递中文参数乱码问题
- jquery向.ashx文件post中文乱码问题的解决
- get/post时中文乱码问题的解决办法
- myeclipse jsp post方式提交中文乱码解决办法
- 中文乱码问题解决,过滤器配置,get post提交乱码,filter,struts乱码,jsp乱码
- 更深入的TOMCAT中文乱码解决之道,包括GET/POST(转)
- AJAX在Post中文的时候解决乱码的方法
- 解决svn post-commit 中文乱码问题
- AJAX在post中文时乱码的解决方法