Parse the summary of all file encoding and garbled characters in java, php, and html. Php file in garbled (such as a. php file in the browser garbled): header (Content-Type: texthtml; charsetutf-8) is set web page. Mysql_query (setnamesutf-8) sets the database.
Php files are garbled (for example, php files are garbled in the browser ):
Header ("Content-Type: text/html; charset = utf-8") sets the webpage.
Mysql_query ("set names UTF-8") sets the database.
Struts in java:
Chinese garbled characters generally mean that when the request parameter has Chinese characters, the correct Chinese characters cannot be obtained in the Action. There are two methods to solve this problem in Struts2:
Set pageEncoding = "UTF-8" on the JSP page to avoid Chinese garbled characters;
If pageEncoding = "GBK" is displayed on the JSP page, modify struts. i18n. encoding = GBK and add the following statement to struts. xml to modify it.
The code is as follows:
"-// Apache Software Foundation // DTD Struts Configuration 2.0 // EN"
Http://struts.apache.org/dtds/struts-2.0.dtd>
......
The above two methods can solve the Chinese parameters in the POST request, but the Chinese parameters in the GET request cannot be resolved. the garbled characters of the Chinese parameters in the GET request must be modified by the Tomcat server. modify the following content by adding URIEncoding = "GBK ":
Encoding (for example, a. php file garbled in the browser): header ("Content-Type: text/html; charset = utf-8") sets the webpage. Mysql_query ("set names UTF-8") sets the database ....