你的MySQL是在中文Windows下吗?是的话,就不用转换了,直接写就OK!

解决方案 »

  1.   

    是中文Windows,但不转换也不行!
      

  2.   

    我用mysql也没有成功过不管我如何做,唉。。
      

  3.   

    难道是跟版本有关?
    Resin 2.1.0
    mysql 3.23.52
    jdk 1.4
      

  4.   

    不知道这里有没有大虾是在Win98上编辑JSP,然后上传到Linux上啊?其中的中文乱码是怎么完全解决的呢?各位的Tomcat和JDK是什么版本的啊?
    我在Win98+Apache1.3+JDK1.4.1+Tomcat3.1+mySql3.23上好好的,在红帽子Linux+Apache1.3+JDK1.4.1+Tomcat3.1+mysql3.23上怎么就有些乱码呢?
    //现在我的做法是每次修改了传到Linux服务器上,然后调试~~特麻烦啊:((
    //下面是我解决中文乱码的完全笔记,是不是有些时候多此一举的啊~~~数据库连接 &useUnicode=true&characterEncoding=GB2312
    在head.jsp里<%@ page contentType="text/html;charset=iso8859_1"%>
    <meta http-equiv='Content-Type' content='text/html; charset=GB2312'>
    JavaBean的编译:javac -encoding iso_8859_1在JavaBean里
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
        { response.setContentType("text/html; charset=GB2312"); }表单提交
    String FA=connect.toGB(request.getParameter("FA"));显示数据库查询记录:out.println(connect.GS(rs.getString("name")));//判断如果点击了"登 陆"按纽
    if(submit.equals(connect.toGB("登 陆")))//直接写入汉字到数据库
    insert into webqq (fromname) values (connect.toGB("本地工作室"));
    //就是不能直接insert into webqq (fromname) values ("本地工作室");//在jsp中传的参数的值为中文
    <a href="profile.jsp?action=show&member=<%=URLEncoder.encode(ffname)%>">
    其中的String ffname=connect.GS(friendname); 即为汉字“系统管理员”//把数据库中取得的结果转化--显示汉字 
    public String GS(String str)
      { try
         { String temp_p=str;
           byte[] temp_t=temp_p.getBytes("GBK");
           String temp=new String(temp_t,"iso8859_1");
           return temp;
          }
        catch(Exception e) { return "null";} 
      }//把表单中提交的中文进行转换
    public String toGB(String iso) { 
    String gb=null; 
      if (iso != null) { 
       try { gb=new String(iso.getBytes("ISO8859_1"),"GB2312"); } 
       catch (Exception e) { gb=null; } 
       } 
      return gb; 
    }//不知道有用没~~~