Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_28929579/article/details/84668179
Phenomenon: (tomcat environment + page UTF-8 + JSP UTF-8)
- When the form post contains Chinese background would accept a similar ç,¹ç,¹æ »'æ» 'This garbled;
- After the form was changed to get the problem solved;
- By distortion String str = new String ( "something" .getBytes ( "ISO-8859-1"), "utf-8") can be reduced to Chinese;
- View through the console as follows:
analysis:
Chinese submitted console displays no problem, the problem occurs in the server; ISO-8859-1, since decoding can be described according to ISO-8859-1 in Chinese encoding described EncodingFilter filter does not work. Then I look at the web.xml configuration is found EncodingFilter filter (filter by filter-mapping node order execution), arguably EncodingFilter filter should be the first filter, the exchange restart in XSSFilter filter, the problem is solved.
to sum up:
- EncodingFilter filter should be the first filter to be performed ( calling getParameter () before response.setCharacterEncoding ( "UTF-8") is provided, java coding analysis will follow all the submission, and subsequent getParameter () is not before being analyzed, so setCharacterEncoding () is invalid ).
- The reason why even possible to submit the get way, because the parameters get behind url then fight utf-8 to encode, when sent to the server, Tomcat URIEncoding configuration to be decoded, as follows:
so EncodingFilter Filter no effect does not matter, thus causing the get crippled phenomenon.
Reference https://www.cnblogs.com/super-z/p/6230119.html