①. Post method:
This method is relatively simple. You only need to add the code in the background as long as the format of the browser page encoding is used in the background:
Request. setcharacterencoding ("SHIFT-JIS"); // encoding format of the browser
②. Get method:
The parameter encoding after the URL is different from the encoding in the HTTP body. It is the default encoding format of the system (for example, the Japanese system isShift_jisThe request URL is encoded by Webserver, not servlet. Therefore, use "request. setcharacterencoding ("SHIFT-JIS"); "this code is invalid, so the solution is (take Tomcat as an example) to modify the Tomcat server. the XML file is as follows:
1 < Service Name = "Catalina" > 2 < Connector Port = "8080" Protocol = "Https/1.1" 3 Connectiontimeout = "20000" Uriencoding= "Shift_jis" 4 Redirectport = "8443" /> 5 </ Service >
Add the following in the configuration file:Uriencoding = "shift_jis". In this way, the parameters after the URL will not be garbled.