Connector
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
当在Connector中添加 URIEncoding="UTF-8" 后,servlet中不设置编码request.setCharacterEncoding("UTF-8");
get方法能解决乱码问题
但post方法不能解决
当post方法中添加设置编码后,乱码问题就解决了.
答案:
此种方法下
get 方法不需要request.setCharacterEncoding("UTF-8");
post 方法需要request.setCharacterEncoding("UTF-8");
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" useBodyEncodingForURI="true" />
当在Connector中添加 useBodyEncodingForURI="true"后,servlet中不设置 编码 request.setCharacterEncoding("UTF-8");
get post 方法均乱码
当servlet中设置编码 request.setCharacterEncoding("UTF-8");后
get post编码问题均都解决了
答案:
此种方法下:
get post方法中都需要request.setCharacterEncoding("UTF-8");