struts.xml里面我设置了i18n.Encoding=gbk,为什么还是会出现乱码。

解决方案 »

  1.   

    设为UTF-8,项目里的所有编码全部换成UTF-8
      

  2.   

    大小写一致,utf-8与UTF-8不一样
      

  3.   

    <constant name="struts.i18n.encoding" value="GBK"/>
    我这样写,没出现乱码,
    另外你看看你的jsp页面是不是加了
    <%@ page contentType="text/html;charset=GBK"%>

    <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
    这两句
      

  4.   

    其实,项目开始的时候,就统一所有都设成UTF-8,这样比较好。
      

  5.   

    这个最好用Spring的拦截器去实现,应该是比较好的方法了。如果不用Spring的话,可以写个filter,也比较简单。相关的具体方法去google一下。一大堆.
      

  6.   


    在struts.xml加上这句
    <constant name="struts.i18n.encoding" value="gb2312" />
    或者在struts.properties中加上这个
    struts.i18n.encoding=gb2312