2012年8月5日 星期日
tomcat default character encoding
in default Tomcat request, we can get null from request.getCharacterEncoding().
what's the default value from Tomcat?
the default value is ISO-8859-1, now we start to trace this path!!
reference:
http://www.docjar.com/html/api/org/apache/catalina/connector/Request.java.html
in method parseParameters():
2496 protected void parseParameters() {
2497
2498 parametersParsed = true;
2499
2500 Parameters parameters = coyoteRequest.getParameters();
2501
2502 // getCharacterEncoding() may have been overridden to search for
2503 // hidden form field containing request encoding
2504 String enc = getCharacterEncoding();
2505
2506 boolean useBodyEncodingForURI = connector.getUseBodyEncodingForURI();
2507 if (enc != null) {
2508 parameters.setEncoding(enc);
2509 if (useBodyEncodingForURI) {
2510 parameters.setQueryStringEncoding(enc);
2511 }
2512 } else {
2513 parameters.setEncoding
2514 (org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING);
2515 if (useBodyEncodingForURI) {
2516 parameters.setQueryStringEncoding
2517 (org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING);
2518 }
2519 }
if we don't add any configuration in /conf/server.xml, it will use default value.
==>
reference:
http://www.docjar.com/html/api/org/apache/coyote/Constants.java.html
the constant:
27 public final class Constants {
28
29
30 // -------------------------------------------------------------- Constants
31
32
33 public static final String DEFAULT_CHARACTER_ENCODING="ISO-8859-1";
shows the default value for Tomcat character encoding!!
if you wanna change setting in server.xml, pls refer to https://confluence.atlassian.com/display/DOC/Configuring+Tomcat's+URI+encoding.
訂閱:
文章 (Atom)