** Notes on migrating from Tomcat 7 to Tomcat 8 **
When Japanese was included in the query parameter of GET at the time of Tomcat7, the characters were garbled. The range of influence was too large to set server.xml to useBodyEncodingForURI = "true", so Previously, the problematic apps were individually fixed as shown below.
String param = new String(parameter.getBytes("ISO_8859_1"));
However, from Tomcat8, if the above support is provided, the characters will be garbled, and rather the support is no longer necessary.
Tomcat7: http://tomcat.apache.org/tomcat-7.0-doc/config/ajp.html Tomcat8: http://tomcat.apache.org/tomcat-8.0-doc/config/ajp.html
Comparing the documents, the explanation of ʻURIEncoding` is different.
Tomcat7
This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.
Specify the URI encoding of the request parameter at the time of GET. ** ISO-8859-1 ** is used if URIEncoding is not specified.
Tomcat8
This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, UTF-8 will be used unless the org.apache.catalina.STRICT_SERVLET_COMPLIANCE system property is set to true in which case ISO-8859-1 will be used.
Specify the URI encoding of the request parameter at the time of GET. ** UTF-8 ** is used if URIEncoding is not specified. However, if the system property org.apache.catalina.STRICT_SERVLET_COMPLIANCE is set to true, ** ISO-8859-1 ** will be used.
The behavior when URIEncoding is not specified has changed.
I tried to set the system property ʻorg.apache.catalina.STRICT_SERVLET_COMPLIANCEto
true, but ʻOrg.apache.catalina.STRICT_SERVLET_COMPLIANCE
seems to be an option to eliminate the difference due to the version change of Tomcat.
Since the range of influence is too wide, I decided to specify ʻISO-8859-1, which is the default of Tomcat7, for ʻURIEncoding
.
conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
redirectPort="8443"
URIEncoding="ISO-8859-1" />
Recommended Posts