把这两段加上,就ok了
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<head>
<title>ss</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
如果是英文系统
要进行编码转换的
在bean里写函数,调用就可以了
 //处理中文问题的自定义函数 
public String getcn(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 setcn(String str)//存
  {
     try
        {
          String temp_p=str;
          byte[] temp_t=temp_p.getBytes("ISO8859_1");
          String temp=new String(temp_t);
          return temp;
         }
      catch(Exception e)
         { return "null";}
  }

解决方案 »

  1.   

    在jsp中加request.setCharacterEncoding("gb2312");或request.setCharacterEncoding("GBK");
      

  2.   

    1. <%@ page contentType="text/html; charset=GB2312" %>
      然后在第一个resquest.getParameterq()前加request.setCharacterEncoding("GB2312");2.将 ' 替换成""
      

  3.   

    你定义一个METHOD
    加个方法:
    <%!public getStr(String str) throws Exception
      {    
        String temp=str;
        byte[] temp_p=temp.getBytes("ISO-8859-1");
        return new String(temp_p,"GBK");;
       }
    %>
    然后在插入数据库之前将有中文的变量用这个方法将变量转换一下:
    String text=null;
    if(request.getParameter("text")!=null&&request.getParameter("text")!="")
    {
       text=getStr(request.getParameter("text"));
     }
      

  4.   

    你不要在什么地方都加,先测试一下,在向数据库插入之前用System.out.println()输出你要的数据,看看输出是否是乱码;如果是乱码,可以用上边提到的方法转换一下:
        String temp=str;
        byte[] temp_p=temp.getBytes("ISO-8859-1");
        return new String(temp_p,"GBK");
    然后在输出看是否是乱码。
    如果不是乱码了,就将数据插入数据库;
    如果在数据库中显示为乱码,那么你在看一下数据库的语言设置,应该是数据库的原因了。
      

  5.   

    我在数据库中直接insert 中文,输入正确
    但是在网页上输出的事乱码!
    若是在网页上输入,则数据库中的也是乱码!
    这是怎么回去?
      

  6.   

    老大 你用的是不是jbuilder,如果是你在选者字体的时候是否选者的是西文,那你的把他改成宋体之类的,才能正确显示!