解决乱码问题的三种方式
1.在control的注解中声明@RequestMapping(value="/httpclient/post", method=RequestMethod.POST,produces=MediaType.TEXT_PLAIN_VALUE+";charset=utf-8")2.在web.xml中配置如下CharacterEncodingFilter
·
1.在control的注解中声明
@RequestMapping(value="/httpclient/post", method=RequestMethod.POST,produces=MediaType.TEXT_PLAIN_VALUE+";charset=utf-8")
2.在web.xml中配置如下
<!-- 解决post乱码 --><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>
3.返回值中进行设置
String studentId = new String(request.getParameter("studentId").getBytes("iso-8859-1"), "utf-8");
更多推荐



所有评论(0)