How does URIEncoding = 'UTF-8' work?

When I browse 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.parseParameters% 28% 29 I can not find where to set the encoding for queryString, which comes from the method of get, and this setting is URIEncoding="UTF-8"

in the server.xml

works in this method.

0


source to share


2 answers


The parameter URIEncoding

is what you are looking for. It sets the character encoding when the URI decodes the query string.

You use it server.xml

as an attribute on an object Connector

.



If it has been used successfully in the past.

+3


source


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

Second, the method parseParameters

does not set the encoding: it selects the encoding set by other components. Some places where content encoding can be set:

  • URIEncoding connector (defaults to ISO-8859-1 AS for HTTP RFC)
  • Encoding the request body (from the Content-Type header of the HTTP request)
  • Another component - perhaps sniffing the encoding by looking at the parameter value


If you just want to accurately set the URI to UTF-8 on your site, just use the attribute URIEncoding

in <Connector>

.

The direct answer to your question is that the server.xml attribute URIEncoding

does not work in this method: it does work elsewhere.

+1


source







All Articles