方案一:
把Tomcat下面conf文件夹下的server.xml文件中:
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" />
修改为:
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
但是不建议去修改这个文件
推荐用方案二:
import java.io.UnsupportedEncodingException;
/**
* doGet转码工具类
* @author Administrator
*
*/
public class Encode{
public static String doEncoding(String string)
{
try {
string= new String(string.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return string;
}
}