<%! 
public String getStr(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;}
  }
%>
<body>
<% 
int       user_id         =0;
String    userName        =getStr(request.getParameter("UserName").trim());
String    userPassword    =getStr(request.getParameter("UserPassword").trim());
String    userFacName     =getStr(request.getParameter("FirmName").trim());
String    userLinkPerson  =getStr(request.getParameter("LinkPerson").trim());
String    userLinkPhone   =getStr(request.getParameter("LinkPhone").trim());
String    userMobile      =getStr(request.getParameter("Mobile").trim());
String    userEmail       =getStr(request.getParameter("Email").trim());
String    userPostalcode  =getStr(request.getParameter("PostalCode").trim());
String    userAddress     =getStr(request.getParameter("Address").trim());
String    userFax         =getStr(request.getParameter("Fax").trim());
String    userHomePage     =getStr(request.getParameter("HomePage").trim());
String    sql_userid      ="select  Max(USER_ID) as max_id from [TIMER_USER]";
conn.DBConnect();
ResultSet rs=conn.executeQuery(sql_userid);
//out.println(sql_userid);
if (rs.next()){
user_id=rs.getInt("max_id")+1;
//out.println(user_id);
}
用getStr()函数,解析一下即可

解决方案 »

  1.   

    String T2=new String(request.getParameter("T2").getBytes("ISO8859_1"), "gb2312");
    out.println(T2);you try
      

  2.   

    //向数据库写入汉字时用
    String name = new String
    (request.getParameter("name").getBytes("ISO-8859-1"), "GB2312");//从数据库读取汉字时用
    String name = new String(rs.getString(3).getBytes("GB2312"), "ISO_8859_1");
      

  3.   

    <% request.setCharacterEncoding("GBK");%>
    在前面加上这句试试.<%@ page contentType="text/html; charset=GB2312" %>
    这句只是对本页面起作用,对request不起作用.
      

  4.   

    Weblogic乱码问题
    对于乱码问题,最根本的是需要确切知道是在那一步操作(client-->servlet/jsp(other components)-->db-->(other components)servlet/jsp-->client)的时候乱的。 
    下面是我们一位工程师对常见中文问题的总结,供参考: 
    &#61548; 情况一:JSP 文件中的中文提示信息不能正确显示 
    解决方法:在JSP 文件中加入 
    <%@ page contentType=“text/html; charset=GBK“ %> 可以解决这个问题。禁止使用这种方法。
    &#61548; 情况二:JSP文件中包含中文提示信息时,不能正确编译 
    解决方法:在weblogic.xml文件的<jsp-descriptor>部分加入 
    <jsp-descriptor> 
    <jsp-param> 
    <param-name>compilerSupportsEncoding</param-name> 
    <param-value>true</param-value> 
    </jsp-param> 
    <jsp-param> 
    <param-name>encoding</param-name> 
    <param-value>GBK</param-value> 
    </jsp-param> 
    </jsp-descriptor> 
    可解决这个问题。 
    &#61548; 情况三:从数据库中检索出来的中文显示不正确时,在这种情况下,如果数据库使用的是中文字符集,并使用的是Type 2 Jdbc Driver时,对于Weblogic 而言,当使用其提供的oci driver时,可加入Weblogic.codeset=GBK的属性可解决这个问题 
    &#61548; 情况四:在JSP文件之间传递中文时,如果不能正确传递中文数据,可在web.xml文件的<web-app></web-app>中间加入
    <context-param> 
    <param-name>weblogic.httpd.inputCharset./*</param-name> 
    <param-value>GBK</param-value> 
    </context-param> 
    可解决这个问题。
    注意context-param的位置按先烈顺序"(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*)"
     
    &#61548; 情况五:为使浏览器能正确显示中文,应在 HTML <HEAD> 部分增加: 
    <meta http-equiv="Content-Type" content="text/html" charset="gbk">
      

  5.   

    现在可以了,我终于看见中文了,可是我的中文信息进了SQL sever2000后是乱码啊?
    我怎么再转换一下啊。谢谢
    辛苦:)
      

  6.   

    来个简单的
      request.setCharactEncoding(gbk);
      

  7.   

    问题解决了。我总结一下。
    最简单的就是<% request.setCharacterEncoding("GBK");%>
    有了它传递中文和往数据库写中文都没有问题了。
    用“用getStr()函数,解析一下即可”,次方法也可以,只是往数据库写中文时还得转换。
    至于“Weblogic乱码问题”,我在BEA的网站上看到过你说的方法,可是我没有成功,我把WEB。XML改了以后,一运行程序,它就又自己变回原来的样子了。没想到解决的办法,大家一起想想办法啊
    。就这么多了,大家还有补充的吗?
    没有的话我就结帐了:)