jsp页面get和post不同导致的乱码问题

一.post请求中默认使用iso-8859-1编码,并且可以进行修改

    request.setCharacterEncoding("utf-8");

二.get请求中默认也使用iso-8859-1编码,但是不能进行修改

方法一:修改tomcat下conf文件夹下,server.xml文件

  <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8"/>

方法二:

String  name=new String(request.getParameter("name").getBytes("iso8859-1"),"utf-8");

posted @ 2018-01-31 14:11  -1℃  阅读(78)  评论(0编辑  收藏  举报