Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

On the problem of codec requested on Tomcat

Shulou Source: shulou.com Published: 2022-06-03 06:56:21 11月15日 Update

Recently, after reading the inside story of in-depth Analysis of Java Web Technology (author: Xu Lingbo), there is a lack of a small point about the coding and decoding of Web requests on Tomcat, which may affect the understanding of some readers. I specially checked it, and it is summarized as follows:

1. The requested PathInfo part is decoded with the encoding specified by the URIEncoding attribute of the Connector element of the Tomcat.

For specific use, please refer to https://tomcat.apache.org/tomcat-8.5-doc/config/http.html.

two。 Second, let's first talk about the parsing of the request body (POST body). Tomcat will get the character code in the next order:

1) the user specifies through a similar code:

2) the encoding specified in the request header of the request message content-type.

3) apply the unified coding configured by web.xml (this is currently in the Servlet4.0 specification)

4) system default ISO8859-1

3. The other is the parsing of the QueryString part. By default, Tomcat uses the same URIEncoding as 1) to parse QueryString. But at the same time Tomcat provides another parameter, useBodyEncodingForURI. Literal meaning uses newspaper style coding to parse QueryString. If the parameter is true. Then Tomcat uses the same encoding as 2) to parse QueryString.

Tags: Code part same parameter problem code author element insider at the same time character literal dot that is attribute situation meaning technology message style Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia OPPO Reno Shulou Tech Info MySQL