request取出的中文为乱码,但是另外的页面是正常的(tomcat)!救急了!up分赃

lifejoy lifejoy 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在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>
...全文
评论 34
收藏 已收藏
分享
返回顶部
lifejoy
Web 开发 81,108 成员 341,721 内容