在论坛上问了一下,暂且找到三个解决方法(谢谢回贴的朋友,呵呵)
方法一
修改$TOMCAT/conf/server.xml文件,在HTTP Connector或者AJP Connector的配置加URIEncoding="gb2312" <... maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="gb2312" /> enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="gb2312" />或使用useBodyEncodingForURI="true". 表示用处理post的方式也对get请求处理 <... maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" useBodyEncodingForURI="true" /> enableLookups="false" redirectPort="8443" protocol="AJP/1.3" useBodyEncodingForURI="true" />
方法二
传值前编码:页面上这么写 <a href="test.jsp?name=encodeURI('学习')"> </a>
服务器解码:接受到name 后, String str = java.net.URLDecoder.decode(name, "UTF8");
方法三
假如上一个页面用的是GBK就这么写就可以了 String name = request.getParameter("name"); name = new String(name.getBytes("ISO-8859-1"), "GBK");
本文介绍了三种解决Tomcat服务器中文乱码问题的方法,包括修改server.xml配置文件、客户端编码及服务器端解码处理。
864

被折叠的 条评论
为什么被折叠?



