Parsing of all file encoding and garbled processing methods for java,php and HTML _php tutorial

Source: Internet
Author: User
PHP files in garbled (such as a.php files in the browser garbled):
The header ("Content-type:text/html;charset=utf-8") is the setting 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 STRUTS.I18N.ENCODING=GBK, add the following statement in the Struts.xml to modify.
Copy the Code code as follows:

"-//apache software foundation//dtd Struts Configuration 2.0//en"
"Http://struts.apache.org/dtds/struts-2.0.dtd" >


......


The above 2 methods can resolve the Chinese parameters in the POST request, but the Chinese parameters in the GET request can not be resolved, the Chinese parameter in GET request is garbled by modifying the Tomcat Server.xml file to resolve, modify the following content, add uriencoding= "GBK" :

http://www.bkjia.com/PHPjc/327821.html www.bkjia.com true http://www.bkjia.com/PHPjc/327821.html techarticle php files in garbled (such as a.php file in the browser garbled): Header ("Content-type:text/html;charset=utf-8") is set up the Web page. mysql_query ("Set names Utf-8") sets the database. ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.