1 mysql5.0
mysql> show variables like 'character%';
+--------------------------+-----------------
| Variable_name            | Value
+--------------------------+-----------------
| character_set_client     | utf8
| character_set_connection | utf8
| character_set_database   | utf8
| character_set_filesystem | binary
| character_set_results    | utf8
| character_set_server     | utf8
| character_set_system     | utf8
| character_sets_dir       | D:\Program Files
+--------------------------+-----------------
8 rows in set (0.00 sec)2 jsp页面里的编码也是UTF-83 浏览器编码也是UTF-8问题:A 从jsp页面输入中文数据,保存到数据库中这些中文全成乱码了
      B 在mysql的可视化环境:navicat中能插入中文数据,没有乱码为什么mysql的设置全为utf8,jsp页面的编码也是UTF-8,怎么还会出现所述情况的中文乱码?!!不解~~

解决方案 »

  1.   

    没加
    ssh中,做了个小测试就这样了
    怎么加过滤器?
      

  2.   

    连接数据库时的url形如:
    jdbc:mysql://localhost/data?useUnicode=true&characterEncoding=utf-8
    注意以上的红色部分!
      

  3.   

    链接在spring中配置了啊:
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://localhost:3306/mytest"></property>
    <property name="username" value="root"></property>
    <property name="password" value="mysql"></property>
    <property name="maxActive" value="100"></property>
    <property name="maxIdle" value="30"></property>
    <property name="maxWait" value="500"></property>
    <property name="defaultAutoCommit" value="true"></property>
    </bean>之前运行好好的,现在要运行这个例子,参考下,结果今天中文都乱码了,头都晕了
    序号  姓  名  年龄  删除  更新  
    65  ç”°  å¦¹  5  delete  update  
    62  张  仙  21  delete  update  
    61  ç†  é‡Œ  11  delete  update  
    60  æŽ  çœŸ  23  delete  update  
    59  烦  燥  33  delete  update  
    58  é‡Œ  é‡Œ  22  delete  update  
    57  åˆ˜  è¿·  22  delete  update  
    48  李  四  33  delete  update 
      

  4.   


    <property name="url" value="jdbc:mysql://localhost:3306/mytest"> </property> 
    改成
    <property name="url" value="jdbc:mysql://localhost:3306/mytest?useUnicode=true&amp;characterEncoding=utf-8"> </property> 
      

  5.   

    在action里查看从页面获取过来的值,是否为乱码
    <filter>
         <filter-name>encodingFilter</filter-name>
         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
         <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
         </init-param>
        </filter>
        <filter-mapping>
         <filter-name>encodingFilter</filter-name>
           <url-pattern>/*</url-pattern>
        </filter-mapping>是的话在页面web.xml里设置以上配置
      

  6.   

    我是楼主
    mysql5.0目录下my.ini文件片段:# MySQL client library initialization.
    #
    [client]port=3306[mysql]default-character-set=utf8
    # SERVER SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by the MySQL Server. Make sure that
    # you have installed the server correctly (see above) so it reads this 
    # file.
    #
    [mysqld]# The TCP/IP Port the MySQL Server will listen on
    port=3306
      

  7.   

    在项目中的web.xml中添加了 还是乱码; 正处于崩溃中……
      

  8.   

    多谢各位了
    查了下,原来是struts2.1.6过滤器的问题,换成struts2.0的过滤器就解决了!
    my god,好像是struts2.1.6的bug~~~
    结贴去,呵呵
      

  9.   

    跟踪一下,插入时内存里是不是乱码;不是的话看再从mysql select出的是否为乱码。找到乱码出来的根源再解决。