request取出的中文为乱码,但是另外的页面是正常的(tomcat)!救急了!up分赃
在tomcat的使用中,原来运行的系统是正常,现在新近在系统上加入了一个新的页面,原来系统正常,但是新的页面运行错误。设置页面解码,和设置字符集都使用了
但是还是出现中文乱码现象。
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>
infoaddsave
</title>
</head>
<jsp:useBean id="conn" scope="page" class="netgate.conn" />
<body>
<%
//String sqlsel=new String(),sqlins=new String();
//String mobile= new String(),specode=new String(),msg=new String();
request.setCharacterEncoding("GBK");
String mobile=(String)request.getParameter("mobile");
String specode=(String)request.getParameter("specode");
String msg=(String)request.getParameter("msg");
byte[] bspecode=specode.getBytes("GBK");
specode=new String(bspecode);
byte[] bmobile=mobile.getBytes("GBK");
mobile=new String(bmobile);
byte[] bmsg=msg.getBytes("GBK");
msg=new String(bmsg);
String sqlsel="select SpCode from login where SgCode='"+specode+"'";
out.print(msg);
ResultSet Rs=conn.executeQuery(sqlsel);
if (Rs.next()){
//String SpCode=new String();
String SpCode=Rs.getString("SpCode");
String sqlins="insert into receivewait (SpCode,UserCode,Message,Mobile) VALUES ('"+SpCode+"','"+
specode+"','"+msg+"','"+mobile+"')";
System.out.print(sqlins);
conn.executeInsert(sqlins);
}
conn.destory();
%>
</body>
</html>