By default, Tomcat uses the encoding method of the iso8859-1
Modify the conf/server. xml file in Tomcat
Find the following code:
<Connector Port = "8080" protocol = "HTTP/1.1" connectiontimeout = "20000" redirectport = "8443"/>
This Code specifies the port number of Tomcat to listen to HTTP requests.
You can add an attribute here: uriencoding, which is set to a UTF-8 so Tomcat (default ISO-8859-1 encoding) can process get requests in UTF-8 encoding.
The changed code is as follows:
<Connector Port = "8080" uriencoding = "UTF-8" protocol = "HTTP/1.1" connectiontimeout = "20000" redirectport = "8443"/>
In addition
You can also add the usebodyencodingforuri = "true" attribute to set the same encoding for post and get.
The changed code is as follows:
<Connector Port = "8080" usebodyencodingforuri = "true" uriencoding = "UTF-8" protocol = "HTTP/1.1" connectiontimeout = "20000" redirectport = "8443"/>