javaweb中的关于编码问题总结

1.pageEncoding=”utf-8” 设置JSP编译成Servlet时使用的编码

2.Contenttype=”text/html;charset=utf-8”对服务器的响应内容的编码方式

3.Request.setCharacterEncoding(“utf-8)客户端请求内容的编码方式

4.Response.setCharacterEncoding(“utf-8”)服务器响应内容的编码方式

对于发送的数据,服务器按response.setCharacterEncoding-contentType-pageEncoding顺序,对发送数据编码。

对于接受数据,分三种情况:

游览器用url提交数据和get提交;

根据tomcat版本,设置userBodyEncodingForURIURIEncoding

userBodyEncodingForURI:根据request.setCharacterEncoding参数对URL数据和get数据编码

URIEncoding:对上述两种做统一编码

post方式提交数据;根据request.setCharsetEncoding参数编码

原文地址:https://www.cnblogs.com/chenkeyu/p/javaweb.html