search
Homephp教程php手册解析关于java,php以及html的所有文件编码与乱码的处理方法汇总

解析关于java,php以及html的所有文件编码与乱码的处理方法汇总

Jun 13, 2016 am 11:45 AM
htmljavaphpandGarbled charactersaboutexistdeal withdocumentmethodSummaryofcodingparse

php文件中在乱码(如a.php文件在浏览器乱码):
header("Content-Type:text/html;charset=utf-8")是设置网页的。
mysql_query("set names utf-8")设置数据库的。

java中的struts:
中文乱码问题一般是指当请求参数有中文时,无法在Action中得到正确的中文。Struts2中有2种办法可以解决这个问题:
设置JSP页面的pageEncoding=”utf-8”,就不会出现中文乱码;
如果JSP页面的pageEncoding=”GBK”,那么需要修改struts.i18n.encoding=GBK,在struts.xml中加入如下语句进行修改。

复制代码 代码如下:



BR>"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">


……


上面2种方法可以解决POST请求中的中文参数,但是GET请求中的中文参数不能解决,GET请求中的中文参数的乱码需要通过修改Tomcat的server.xml文件来解决,修改如下内容,加入URIEncoding=”GBK”:
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function