jsp中 如何传递中文参数 且让接收端能正确识别并显示 谢谢各位(是不是很简单)?

p559 2003-04-02 04:16:47
以下为提交表:
************************************************************************

<%@ page contentType="text/html; charset=gb2312" language="java" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test1</title>
</head>

<body>
<form name="form" method="post" action="test.jsp">
<input name="name" type="text" id="name">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
************************************************************************
当在文本框输入中文并提交时,在以下的页面输出发现乱码。请问如何解决??万万分感谢!!!
*********************************************************************************
<%@ page contentType="text/html; charset=GBK" language="java" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
</head>

<body>
<form name="form" method="post" action="test.jsp">
<input name="name" type="text" id="name">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>

...全文
48 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
p559 2003-04-03
  • 打赏
  • 举报
回复
感谢楼上的各位同僚,问题解决了。
我看过以前的纪录是
String name = new String(request.getParameter("name").getBytes("8859_1"));
就OK了。
anhuihefei 2003-04-02
  • 打赏
  • 举报
回复
<%!
public String getStr(String str){
try{
byte[] temp_t=str.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e){}
return "null";
}
%>

<%
String name=getStr(request.getParameter("name"));
%>

—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂        ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃        ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛       ▲自动添加签名......

让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip
anhuihefei 2003-04-02
  • 打赏
  • 举报
回复
<%!
public String getStr(String str){
try{
byte[] temp_t=str.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e){}
return "null";
}
%>

<%
String name=getStr(request.getParameter("name"));
%>

—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂        ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃        ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛       ▲自动添加签名......

让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip
springgwn 2003-04-02
  • 打赏
  • 举报
回复
同意wellsoon(wellsoon)!
ppdy 2003-04-02
  • 打赏
  • 举报
回复
同上!
wellsoon 2003-04-02
  • 打赏
  • 举报
回复

<%@ page contentType="text/html; charset=gb2312" language="java" %>

下面加上一行:

<%
request.setCharacterEncoding("GB2312");//设置编码
%>

在你的 test.jsp里也这样做。


81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧