post提交:
设置实体内容的编码:request.setCharacterEncoding("utf-8");
注意:一定要在获取所有参数之前设置,否则设置无效!
get方式提交
(1)手动进行参数的解码
String paramValue = new String(paramValue.getBytes(("iso-8859-1"),"utf-8"))
(2)修改tomcat的配置文件
修改%tomcat%/conf/server.xml,加上URIEncoding属性。内容如下:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="utf-8"/>