Summary of Chinese garbled code processing methods in URL links by JSP
Ie does not encode the parameters after the URL by default, but tomat encodes the URL according to iso8859-1 by default, so an error will occur.
Method 1:
Re encode the URL link:
Or separately encode the parameters:
Someone has asked why you should repeatedly encode the string twice on the client side?
If the coding rules used by the container to decode the submitted parameters cannot be specified because of the needs of the project, for example, when the parameter contents from different pages need to be received without encoding. (or developers are confused by this complex thing and don't know how to correctly receive parameters)
At this time, the secondary encoding of parameters on the client can effectively avoid the thorny problem of "submitting multi byte characters".
Because of the first encoding, your parameter content will not contain multi byte characters and become a pure ascii string. (here, call the result of the first compilation as [str_enc1]. [str_enc1] does not contain multi byte characters)
After compiling again, submit and automatically disassemble the container when receiving (this time, the container can be automatically disassembled according to GBK, UTF-8 or iso-8859-1, and [str_enc1] can be obtained correctly)
Then, the original value of the parameter to be submitted can be obtained by implementing the decodeuricomponent in the program (java.net.urldecoder.decode (* * *, "UTF-8") is usually used in Java).
To put it simply, the Tomcat server will automatically make a urlcode for you, plus the urlcode you wrote in the service code, there are two decodes in total. Since you need to decode twice, of course, you need to encode twice. You may ask, just encode once, and then do not decode in Java code. Hehe, this is also not good. In fact, this is the reason why encode twice.
Method 2: (IE8 is not supported after testing)
Method 3:
Method 4: set server in Tomcat The connector in XML is familiar with uriencoding = "UTF-8" to ensure that the decoding format is consistent with the encoding format.