Wildfly8 POST request Chinese garbled analysis and solution, wildfly8 Chinese
Recently, I encountered a problem about Chinese garbled characters in POST requests. The original application was running on TOMCAT. After switching to Wildfly8, the test environment was normal, however, in the production environment, garbled characters are generated on the server for the same request sent by the client. After locating the request, it is found that it is caused by a configuration of Wildfly8.
The problem is analyzed as follows:
In the http post request, if this is the case, Content-Type: application/x-www-form-urlencoded; charset = UTF-8, if charset = UTF-8 is not set, in this case, the request parameters may contain Chinese Characters in garbled characters. For details, see the Servlet container configuration. In TOMCAT, if useBodyEncodingForURI = "true, the Request will be decoded using UTF-8 when parsing the Request body parameters, and no garbled characters will appear. If useBodyEncodingForURI = "false", Chinese garbled characters will appear; configurations with the same role in Wildfly are available in Configuration-> Web-> Servlets-> Common-> Default encoding. If Default encoding is set to UTF-8, Chinese garbled characters are not displayed. If it is set to null, chinese characters are displayed. Garbled, the container by default is the use of ISO 8859-1 decoding, for POST requests encoded with UTF-8, Chinese decoding error, English and numbers are not affected.
Chinese garbled Configuration
Set the default codec mode configuration
The official configuration definition is as follows:
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.