php文件中在亂碼(如a.php文件在瀏覽器亂碼):
header("Content-Type:text/html;charset=utf-8")是設(shè)置網(wǎng)頁的。
mysql_query("set names utf-8")設(shè)置數(shù)據(jù)庫的。
java中的struts:
中文亂碼問題一般是指當請求參數(shù)有中文時,無法在Action中得到正確的中文。Struts2中有2種辦法可以解決這個問題:
設(shè)置JSP頁面的pageEncoding=”utf-8”,就不會出現(xiàn)中文亂碼;
如果JSP頁面的pageEncoding=”GBK”,那么需要修改struts.i18n.encoding=GBK,在struts.xml中加入如下語句進行修改。
復(fù)制代碼 代碼如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant value="GBK"/>
……
</struts>
新聞熱點
疑難解答