The php file is garbled (for example, the a.php file is garbled in the browser):
header("Content-Type: text/html; charset=utf- 8") is for setting up the web page.
mysql_query("set names utf-8") sets the database.
Struts in java:
The Chinese garbled problem generally means that when the request parameter has Chinese, the correct Chinese cannot be obtained in the Action. There are two ways to solve this problem in Struts2:
Set the pageEncoding="utf-8" of the JSP page, and there will be no Chinese garbled characters;
If the pageEncoding="GBK" of the JSP page, then It is necessary to modify struts.i18n.encoding=GBK and add the following statement to struts.xml for modification.
Copy code 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 solved. The garbled Chinese parameters in the GET request need to be solved by modifying Tomcat's server.xml file. To solve the problem, modify the following content and add URIEncoding="GBK":
http://www.bkjia.com/PHPjc/327821.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327821.htmlTechArticleThe php file is garbled (for example, the a.php file is garbled in the browser): header("Content-Type: text/html;charset=utf-8") is used to set the web page. mysql_query("set names utf-8") sets the database. ...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn