| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2179 人关注过本帖
标题:传递中文产生乱码!生气呀
取消只看楼主 加入收藏
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
 问题点数:0 回复次数:11 
传递中文产生乱码!生气呀
我使用如下语句:response.sendRedirect("error.jsp?msg=您的输入有误!");error.jsp页面中的接收语句为:String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");可是当显示变量msg的时候就是乱码,各位,请教了!
搜索更多相关主题的帖子: 乱码 生气 中文 
2007-02-05 11:00
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 
能说具体点吗?怎样转呢?

知识改变命运!!!
2007-02-05 11:04
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 
先谢过了,兄弟,我试一下!

知识改变命运!!!
2007-02-05 11:09
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 
这个是有的.已经加了,但还是不行.

知识改变命运!!!
2007-02-05 14:38
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 
8楼的xd,能明确告诉我该如何写吗?String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");语句该怎么写呢?

知识改变命运!!!
2007-02-06 08:54
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 

还是不行呀!


知识改变命运!!!
2007-02-06 09:32
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>公司管理系统</title>
<style type="text/css">
<!--
body {
background-image: url(image/bj.gif);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style2 {color: #0033FF}
-->

</style></head>
<body>
<%
request.setCharacterEncoding("gb2312");

request.getSession(true);
String name=new String(request.getParameter("user").getBytes("ISO8859_1"),"GBK");

String password=new String(request.getParameter("pass").getBytes("ISO8859_1"),"GBK");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:mydata";
String username="";
String pass="";
Connection con=DriverManager.getConnection(url,username,pass);
Statement stmt=con.createStatement();
String sql="select * from wglperson where username='"+name+"'and password='"+password+"'";
ResultSet rs=stmt.executeQuery(sql);
if (rs.next())
{
int web=rs.getInt("web");
String personid=rs.getString("username");
session.setAttribute("personid",personid);
if (web==1)
{
%>

<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="800" border="0"align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
</tr>
<tr>
<td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
<td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
</tr>
<tr>
<td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
</tr>
<tr><td colspan="6"> <h3 align="center" class="style2">欢迎进入管理员界面</h3></td></tr>
<tr>
<td height="340"><img src="image/separator.gif" width="2" height="340"></td>
<td width="95">dfd</td>
<td width="127"><div align="right">dfd</div></td>
<td width="113">dfd</td>
<td width="100">dfd</td>
<td width="200"><div align="right"><img src="image/separator.gif" width="2" height="340"></div></td>
</tr>
<tr>
<td>dfd</td>
<td width="95">dfd</td>
<td width="127">dfd</td>
<td width="113">dfd</td>
<td width="100">dfd</td>
<td width="200">dfd</td>
</tr>
<tr>
<td>dfd</td>
<td width="95">dfd</td>
<td width="127">dfd</td>
<td width="113">dfd</td>
<td width="100">dfd</td>
<td width="200">dfd</td>
</tr>
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
</tr>
<%}

if (web==2)
{
%>

</table>

<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="800" border="0"align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
</tr>
<tr>
<td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
<td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
</tr>
<tr>
<td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
</tr>
<tr>
<td>

</td>
<td colspan="4"><p align="center"><font size="+3" color="#0033FF" >欢迎光临领导用户界面</font></p></td>
<td width="139">&nbsp;</td>
</tr>
<tr>
<td height="400"><img src="image/separator.gif" width="2" height="400"></td>
<td width="149">&nbsp;</td>
<td width="133"></td>
<td width="156">&nbsp;</td>
<td width="76">&nbsp;</td>
<td width="139"><div align="right"><img src="image/separator.gif" width="2" height="400"></div></td>
</tr>
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58">
<%}

if (web==0)
{
%>

</table>

<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="599">
<table width="800" border="0"align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
</tr>
<tr>
<td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
<td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
</tr>
<tr>
<td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
</tr>
<tr>
<td height="26">

</td>
<td colspan="4"><p align="center"><font size="+3" color="#0033FF" >欢迎光临普通用户界面</font></p></td>
<td width="139">&nbsp;</td>
</tr>
<tr>
<td height="360"><img src="image/separator.gif" width="2" height="360"></td>
<td width="165"><a href="yuangong/rest.jsp"><img src="image/qj.jpg" width="150" height="55" border="0"></a></td>
<td width="117"></td>
<td width="156"><a href="yuangong/restuser.jsp"><img src="image/qjcx.jpg" width="150" height="55" border="0"></a></td>
<td width="76">&nbsp;</td>
<td width="139"><div align="right"><img src="image/separator.gif" width="2" height="360"></div></td>
</tr>
<tr>
<td height="61" colspan="6"><img src="image/top2.gif" width="800" height="58"><% }}

else
{
rs.close();

response.sendRedirect("error.jsp?msg=您好的输入有错误!");


}

%></td>
</tr>

</table>

</td>
</tr>
</table>



</body>
</html>
以下是error.jsp的内容
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>公司内部系统---</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(image/bj.gif);
}
.style1 {
font-size: 16px;
font-weight: bold;
}
.style2 {
color: #0066FF;
font-weight: bold;
font-size: 18px;
}
-->
</style></head>
<SCRIPT LANGUAGE="JavaScript">
function setf()
{
document.for1.user.focus();
}
function cancle()
{ document.for1.user.value="";
document.for1.pass.value="";
return false;
}
function selec(txt)
{
txt.focus();
txt.select();
}
function chkUser(txt)
{ var user = document.for1.user;
if (user.value=="")
{
alert ("please input username");
selec(txt);
return false;
}else{
return true;}
}
function chkPw(txt)
{ var pw = document.for1.pass;
if (pw.value=="")
{
alert ("please input password");
selec(txt);
return false;
}else{
return true;}
}
function chkUserPw()
{var user = document.for1.user;
var pw = document.for1.pass;
if(chkUser(user))
{
if(chkPw(pw))
{
return true;
}
return false;
}
return false;
}
</SCRIPT>

<body>
<table width="800" border="0"align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
</tr>
<tr>
<td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
<td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
</tr>
<tr>
<td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="55">&nbsp;</td>
<td width="301"><div align="center" class="style2">公司内部管理系统</div></td>
<td width="54">&nbsp;</td>
<td width="89">&nbsp;</td>
<td width="136">&nbsp;</td>
</tr>
<tr>
<td height="300"><img src="image/separator.gif" width="2" height="400"></td>
<td>&nbsp;</td>
<td><form action="logo.jsp" name="for1" method="post" onSubmit="return chkUserPw()"><table width="100%" border="0" >
<tr>
<td width="29%">&nbsp;</td>
<td width="31%"><span class="style1">username</span></td>
<td width="29%">&nbsp;</td>
<td width="11%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="text" name="user" size="12">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><span class="style1">password</span></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="password" name="pass" size="16">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center"><input type="image" border="0" name="imageField" src="image/login.gif" width="60" height="25"></td>
<td>&nbsp;</td>
<td><input type="image" border="0" name="imagereset" src="image/reset.gif" width="60" height="25" onClick="return cancle();"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<%
request.setCharacterEncoding("gb2312");

String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");
if(msg!=null)
out.print("<br>"+msg);
%>
</td>
<td>&nbsp;</td>
</tr>
</table>
</form></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><img src="image/separator.gif" width="2" height="400" align="right"></td>
</tr>
<tr>
<td colspan="6"><img src="image/top1.gif" width="800" height="58"></td>
</tr>
</table>
</body>
</html>
红色部分为所述代码!


知识改变命运!!!
2007-02-06 17:55
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 

我在String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");之前有加这句呀,request.setCharaterEncoding("GB2312");


知识改变命运!!!
2007-02-07 10:55
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 

这一步我做了!


知识改变命运!!!
2007-02-07 15:32
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 

也试了,产生错误信息
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 170 in the jsp file: /www/logo.jsp

Generated servlet error:
[javac] Compiling 1 source file

D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:299: unclosed string literal
response.sendRedirect("error.jsp?msg=<%=URLEncoder.encode('?ㄥソ????ユ????!')
^

An error occurred at line: 173 in the jsp file: /www/logo.jsp

Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:300: ')' expected
out.write("\");\r\n\t }\r\n\t \r\n\t %>");
^

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:309: 'catch' without 'try'
} catch (Throwable t) {
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:31: 'try' without 'catch' or 'finally'
try {
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:319: '}' expected
^
5 errors
我是直接搬上去的.


知识改变命运!!!
2007-02-07 16:02
快速回复:传递中文产生乱码!生气呀
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020417 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved