标签:cti ctp value connect byte work prot bean 控制
1 request.setCharacterEncoding("utf-8"); 2 response.setContentType("text/html;charset=utf-8");
3. 然后发现JavaBean获取到的就是乱码,在web.xml配置文件加入了过滤器设置编码格式;(这是针对post请求)
1 <filter> 2 <filter-name>encoding</filter-name> 3 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 4 <!-- 设置编码参是UTF8 --> 5 <init-param> 6 <param-name>encoding</param-name> 7 <param-value>UTF-8</param-value> 8 </init-param> 9 </filter> 10 <filter-mapping> 11 <filter-name>encoding</filter-name> 12 <url-pattern>/*</url-pattern> 13 </filter-mapping>
针对get请求乱码情况,查阅得知两种解决办法:
<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
String userName = new String(request.getParamter("userName").getBytes("ISO8859-1"),"utf-8");
标签:cti ctp value connect byte work prot bean 控制
原文地址:https://www.cnblogs.com/Johnny-yu/p/11268355.html