Get the App
SLTechnology News&Howtos  ›  Development  › 

How to deal with all the file coding and garbled problems of java,php and html

Shulou Source: shulou.com Published: 2022-06-03 05:57:58 11月17日 Update

This article mainly shows you "how to deal with all java,php and html file coding and garbled problems", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to deal with java,php and html all file coding and garbled problems" this article.

Garbled in php file (for example, a.php file is garbled in browser):

Header ("Content-Type:text/html;charset=utf-8") is used to set up a web page.

Mysql_query ("set names utf-8") sets the database.

Struts in java:

Chinese garbled generally means that when the request parameter has Chinese, the correct Chinese cannot be obtained in Action. There are two ways to solve this problem in Struts2:

If you set the pageEncoding= "utf-8" of the JSP page, there will be no Chinese garbled.

If the pageEncoding= "GBK" of the JSP page, then you need to modify the struts.i18n.encoding=GBK by adding the following statement to the struts.xml to modify it.

The copy code is as follows:

……

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 codes of the Chinese parameters in the GET request need to be solved by modifying the server.xml file of Tomcat. Modify the following contents and add URIEncoding= "GBK":

The above is all the contents of this article entitled "how to deal with all the file coding and garbled problems of java,php and html". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Garbled files Chinese questions content parameters coding articles code pages utf-8 learning help methods data databases methods easy to understand more Chinese Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Shulou Tech Info Redmi MySQL