解决SpringMvc框架中文乱码问题
2016-11-21 18:37
483 查看
1、检测web.xml配置是否ok
<filter>
<description>字符集过滤器</description>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<description>字符集编码</description>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
</filter>
2、对Servlet的HttpServletResponse的属性进行设置
response.setCharacterEncoding("text/html,charset=utf-8");
3、requestMapping添加配置produces = {"application/json;charset=UTF-8"}
requestMapping(value = { "getPackageList"}, method = {RequestMethod.POST, RequestMethod.GET}
,produces = {"application/json;charset=UTF-8"})
<filter>
<description>字符集过滤器</description>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<description>字符集编码</description>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
</filter>
2、对Servlet的HttpServletResponse的属性进行设置
response.setCharacterEncoding("text/html,charset=utf-8");
3、requestMapping添加配置produces = {"application/json;charset=UTF-8"}
requestMapping(value = { "getPackageList"}, method = {RequestMethod.POST, RequestMethod.GET}
,produces = {"application/json;charset=UTF-8"})
相关文章推荐
- springMvc框架解决返回Json格式中文乱码问题
- springMVC_json格式数据的接收和发送(未解决中文乱码问题)
- springmvc Spring3 MVC @ResponseBody返回,jquery ajax调用中文乱码问题解决
- SpringMVC学习系列-后记 解决GET请求时中文乱码的问题
- SpringMVC与fastjson整合并同时解决中文乱码问题
- SpringMVC学习系列-后记 解决GET请求时中文乱码的问题
- springmvc Spring3 MVC @ResponseBody返回,jquery ajax调用中文乱码问题解决
- iOS 文件下载 (AFNetwork 三方框架 文件名中文字符乱码问题解决)四
- SpringMVC 解决中文乱码的问题
- Android Volley框架(三):解决Volley请求服务器返回中文乱码问题
- springmvc Spring3 MVC @ResponseBody返回,jquery ajax调用中文乱码问题解决
- 解决plupload-2.1.2,springmvc上传中文文件名乱码问题
- springmvc解决post中文乱码问题
- SpringMVC的@ResponseBody返回JSON,中文乱码问题的解决.
- 解决SpringMVC通过model设置中文消息乱码问题
- CI框架下,上传中文文件和发送中文邮件的标题乱码问题解决
- 解决springmvc的get提交和post提交的中文乱码问题
- springmvc Spring3 MVC @ResponseBody返回,jquery ajax调用中文乱码问题解决
- 解决SpringMVC中文乱码问题以及配置不生效问题
- SpringMVC 解决GET请求时中文乱码的问题