出现乱码时可以从四个方面做检查;
1.Tomcat 的 conf 下的server.xml文件中将
<Connector port="8080" protomcol="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"/>
2.然后再servlt中配置如下;
如果你用的是post方式;
request.setCharacterEncoding("utf-8");
respnose.setCharacterEncoding("utf-8");
get方式:
String string=requset.getParamers("");
String = new String(string.getBytes("ISO8859-1","utf-8"));
3.jsp 页面中 <%@ page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
4.在Eclipse或者MyEclipse的话。那么在window的preference中的左上角的输入框输入
seplling在spelling这个页面中看看Enconding默认是否设置为utf-8;