终于到了不得不用get请求的时候了,乱码问题也产生了!get请求乱码使用过滤器也不能解决,有位仁兄说可能是因为请求在到达过滤器以前就已经是乱码了……两种方式解决:
1.获取请求后处理
String province = new String((request.getParameter("province")).getBytes("ISO-8859-1"),"GBK");
轻松搞定,方便快捷。适合使用少量的中文get请求。
2.请求到达前避免
修改tomcat的配置文件:servle.xml,
<Connector port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK" />
优点是一劳永逸,适合有大量中文get请求的情况;
缺点是部署时容易遗忘,如果使用,啥都别干,先写文档记下来吧!
浙公网安备 33010602011771号