建议使用过滤器,全都过滤成UTF-8的,就省的考虑那么多问题了!

解决方案 »

  1.   

    另外那个转换好象是这么写的: 
    String a=new String(request.getParameter("Submit").getBytes("iso-8859-1"),"utf-8");
      

  2.   

    my.ini
    要修改两处.把JSP 也设置成相同的编码!String a=new String(request.getParameter("Submit").getBytes("iso-8859-1"),"utf-8");//这个转码不要.,直接SAVE就可以.
      

  3.   

    改为utf8也没反应不知道怎么回事
    想不通试试filter哎
    用sql server也没这么多事啊
      

  4.   

    my.ini
    改的是两处啊# The following options will be passed to all MySQL clients
    [client]
    #password = your_password
    port = 3306
    socket = /tmp/mysql.sock
    default-character-set=utf8 # Here follows entries for some specific programs# The MySQL server
    [mysqld]
    port = 3306
    socket = /tmp/mysql.sock
    skip-locking
    key_buffer = 16M
    max_allowed_packet = 1M
    table_cache = 64
    sort_buffer_size = 512K
    net_buffer_length = 8K
    read_buffer_size = 256K
    read_rnd_buffer_size = 512K
    myisam_sort_buffer_size = 8M
    default-character-set=utf8
      

  5.   

    你把url中的?useUnicode=true&characterEncoding=GBK去掉,然后在jsp中的page标签中加个pageEncoding="utf-8".接在修改tomcat下的server.xml文件:在<connector port="8080" protocal="HTTP/1.1" ... 后加一句:URIEncoding="UTF-8" />
      

  6.   

    jsp页中加了
    <%@ page language="java" contentType="text/html; charset=UTF-8 " import="java.sql.*"
        pageEncoding="UTF-8"%>
    驱动连接改了
    sConnStr = "jdbc:mysql://localhost:3306/testhospital";server.xml改了
        <Connector
    port="8090"               maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8"/>还不行啊~~~~~~
      

  7.   

    ini有两个地方要改,默认是latin
      

  8.   

    用过滤器就不用管页面和数据库的编码了吧
    我刚加了
    也配置了web.xml文件
    <?xml version="1.0" encoding="GBK"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>
    first</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <filter> 
    <filter-name>Set Character Encoding</filter-name> 
    <filter-class>filter.SetCharacterEncodingFilter</filter-class> 
    <init-param> 
    <param-name>encoding</param-name> 
    <param-value>GBK</param-value> 
    </init-param> 
    <init-param> 
    <param-name>ignore</param-name> 
    <param-value>true</param-value> 
    </init-param> 
    </filter> <filter-mapping> 
    <filter-name>Set Character Encoding</filter-name> 
    <url-pattern>/*</url-pattern> </filter-mapping>
    </web-app>还是没解决~~~~
      

  9.   

    不行的话,就把GBK 的转成UTF 8的,看他Y的还乱码不
      

  10.   

    这个问题主要是在于你必须知道是在插入的时候是乱子码还是在读取的时候是乱吗,这样才好解决问题
    另外给你一个强制转换的代码对任何的乱码问题都实用:
    new String(request.getAttribute("要得到的值名称").toString().getBytes("ISO-8859-1"),"GBK");
      

  11.   


    当时不知道
    知道后很可笑
    我是在jsp中写不到数据库
    因为类型不匹配
    获取的是字符串型
    数据库设置的是整型
    汗啊
    不好意思啊
    咳咳....
    闪了~~~~~