Recently completed a project, which encountered two times more bizarre garbled problem, recorded here, to give himself a wake-up call, but also for the latter to provide reference.
This is a project that is implemented with SSH, in order to prevent garbled, from the database to the page code, and then to struts the default encoding all set to Utf-8 (the specific settings online there are a lot of information, here do not repeat it), thinking that this will be able to have no future, but things have not been so smooth.
1. Submit form using post all the data is normal, and the way to submit the form using get is garbled in Chinese. This is because of the URL encoding problem, the URL of the default encoding is not utf-8, so you need to modify the Server.xml in Tomcat folder to join uriencoding= "UTF-8"
<connector uriencoding= "UTF-8" connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443"/ >
2. All the data on the page show normal, including Chinese, no garbled. But open source file found as long as the data from the back of the struts tag is garbled, similar to a bunch of numbers. In general, this problem has no effect, after all, the page appears normal, but when displaying the displayed data submitted by the Rich text box, it will print out the label information directly, instead of parsing, if the bold <b> should be shown, the <b>...</b> will be printed directly. At first very confused, later a think, from the background to get the data is normal, why the page will appear this situation, the problem is certainly on the struts label, then a check tag Reference, found <s:property/> There is a property called escape default is True, meaning will skip parsing of HTML, so as long as the set escape= "false" will not have a problem, and then look back at the source file, the content page is normal.
This column more highlights: http://www.bianceng.cn/webkf/JSP/