How does URIEncoding = 'UTF-8' work?

前端 未结 2 1503
时光取名叫无心
时光取名叫无心 2021-01-28 10:55

When I view the tomcat source code at http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.0/org/apache/catalina/connector/Request.java#Request.

2条回答
  •  庸人自扰
    2021-01-28 11:25

    First, let's use a more recent version of Tomcat. 7.0.0 is years old: Request.java from Tomcat 7.0.34

    Second, the parseParameters method does not set the encoding: it fetches the encoding which has been set by other components. Some places where the content encoding might have been set:

    1. The URIEncoding of the connector (defaults to ISO-8859-1 AS per HTTP RFC)
    2. The request body encoding (from the HTTP request's Content-Type header)
    3. Another component -- perhaps sniffing the encoding by looking at a parameter's value

    If you just want to set the URI encoding to UTF-8 unconditionally across your site, then just use the URIEncoding attribute in your .

    The direct answer to your question is that server.xml's URIEncoding attribute does not work in this method: it works elsewhere.

提交回复
热议问题