正在写一个项目,但用表单提交数据到Action类进行处理时中文全是乱码!设置了filter 编码是GBK  页面也统一设置了pageEncoding="gbk",contentType="text/html;charset=gbk"
但一提交数据就是乱码???这个问题该怎么解决啊???希望各位仁兄帮帮忙啊!!!

解决方案 »

  1.   

    action 中 输出的就是乱码吗,那过滤器没起到作用呢   
      

  2.   

    对,action输出的就是乱码,我用request.getCharacter()和response.getContentType()取出来看了字符编码是GBK和text/html;charset=GBK;
      

  3.   

    gbk换成 UTF-8 试试 
      还是编码的问题
      

  4.   

    页面统一用utf_8编码!
    如果不行你就硬编码 new String("","")!
      

  5.   

    <hibernate-configuration><session-factory>
    <property name="dialect">
    org.hibernate.dialect.MySQLDialect
    </property>
    <property name="connection.url">
    jdbc:mysql://127.0.0.1:3306/netctoss?useUnicode=true&amp;characterEncoding=gbk
    </property>
    <property name="connection.username">root</property>
    <property name="connection.driver_class">
    com.mysql.jdbc.Driver
    </property>
    <property name="myeclipse.connection.profile">mysqlDriver</property>
    <property name="show_sql">true</property>
    <property name="connection.password"></property>
    </session-factory></hibernate-configuration>
    加上这个,行的话给点分小弟下资料
    jdbc:mysql://127.0.0.1:3306/netctoss?useUnicode=true&amp;characterEncoding=gbk
      

  6.   

    楼主是不是从数据库取得数据还是从页面到Action中间出了问题,先定位问题再说
      

  7.   

    我查了一些资料,楼主可以试试
    1. 在struts2里面,最好将所有字符都设成utf-8。 <%@ page contentType="text/html; charset=UTF-8"%> <%@ page pageEncoding="UTF-8" %>1.1 在jsp页面设定字符编码。这边有必有说明的是如果是jsp+java bean+servlet的方案,中文乱码很好解决,统一设成gb2312就可以了。    1.2 使用struts框架字符集不能设成gb2312,要改成utf-8。 
     2. 在struts.properties 添加: 
    struts.devMode=false struts.enable.DynamicMethodInvocation=true struts.i18n.reload=true struts.ui.theme=simple 
    struts.locale=zh_CN struts.i18n.encoding=UTF-8 
    struts.serve.static.browserCache=false struts.url.includeParams=none 
    其中locale、encoding就是字符集的设定了。 
      3. 在web.xml加个filter 
      <!-- zh-cn encoding -->    <filter>        <filter-name>struts-cleanup </filter-name>        <filter-class>            org.apache.struts2.dispatcher.ActionContextCleanUp        </filter-class>    </filter>      <filter-mapping>        <filter-name>struts-cleanup </filter-name>        <url-pattern>/* </url-pattern>    </filter-mapping> 
      

  8.   

    我就遇到这个问题,估计是楼主的过滤器没配置好,配置在<servlet>后面.放在前面就不起作用了。