PHP files in garbled (such as a.php files in the browser garbled):
Header ("Content-type:text/html;charset=utf-8") is the setting of the page.
mysql_query ("Set names Utf-8") sets the database.
Struts in Java:
Chinese garbled problem generally refers to when the request parameter has Chinese, cannot get the correct Chinese in the action. There are 2 ways to solve this problem in Struts2:
Set JSP page pageencoding= "Utf-8", will not appear in Chinese garbled;
If the JSP page pageencoding= "GBK", then you need to modify the STRUTS.I18N.ENCODING=GBK, add the following statement to the Struts.xml to modify.
Copy Code code as follows:
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Struts Public
"-//apache Software foundation//dtd Struts Configuration 2.0//en"
"Http://struts.apache.org/dtds/struts-2.0.dtd" >
<struts>
<constant name= "struts.i18n.encoding" value= "GBK"/>
......
</struts>
The above 2 methods can resolve the Chinese parameter in post request, but the Chinese parameter in GET request cannot be solved, the garbled character of the Chinese parameter in GET request needs to be solved by modifying Tomcat's Server.xml file, modify the following content, join uriencoding= "GBK" : <connector port= "8080" ... uriencoding= "GBK"/>