使用tomcat的情况:
有下面几个地方需要你看看是否配置正确:
(1)Tomcat 的 conf 下的server.xml文件中将
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
里添加上后面3个编码的设置
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
useBodyEncodingForURI="true"
IEncoding="utf-8"
URIEncoding="utf-8"/>
其它情况通用的配置:
在servlet中配置如下:
如果你用的是 post方式
解决方案:
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding( "utf-8" );
get方式
String string = request。getParamers("");
String = new String(string.getBytes("ISO8859-1","utf-8"));
jsp页面中 pageEncoding="UTF-8"
如果你用的是Eclipse或者MyEclipse的话,那么你在window 下的preferences中的左上角的输入框中输入spelling 在spelling这个页面中看看Encoding 默认是否设置为utf-8