aspx和jsp的互相传值!!!!

Legand1978 2004-05-10 02:59:31
我的目的是:从一个aspx中向一个jsp发送参数,然后接受该jsp的反馈信息。
string URL="http://192.168.1.10/web/send.jsp?msg=" + "成功";

WebRequest wr = WebRequest.Create(URL);
WebClient wc = new WebClient();
Stream str = wc.OpenRead(URL);
StreamReader sr = new StreamReader(str);
string line, content = "";
while( ( line = sr.ReadLine() ) != null )
content += line;

wc.Dispose();
sr.Close();

jsp中使用request.getParameter来获取参数信息,参数msg的内容为汉字时得到的是乱码,比如???,英文时正常。

请问如何解决这个问题呢?
...全文
107 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangdequan1024 2004-09-03
  • 打赏
  • 举报
回复
Up,学习
tl0 2004-09-03
  • 打赏
  • 举报
回复
用UTF-8
Legand1978 2004-09-03
  • 打赏
  • 举报
回复
今天揭贴,来者有分啊!!
boyxia 2004-09-03
  • 打赏
  • 举报
回复
不建议用中文
hebookboy 2004-09-03
  • 打赏
  • 举报
回复
加上支持中文的代码charset="gb2312"
wwj9252003 2004-09-03
  • 打赏
  • 举报
回复
在jsp页面中加上 charset="gb2312"
Legand1978 2004-05-10
  • 打赏
  • 举报
回复
Server.UrlEncode/Server.UrlDecode
是什么意思?
gabriel1 2004-05-10
  • 打赏
  • 举报
回复
Server.UrlEncode/Server.UrlDecode
Legand1978 2004-05-10
  • 打赏
  • 举报
回复
还有:aspx传过去的中文参数是不是也要编码,比如%e6%b3%a8%e5%86%8c%e6%88%90%e5%8a%9f,还是直接写汉字?
Legand1978 2004-05-10
  • 打赏
  • 举报
回复
多谢!再问一下
String(aParam.getBytes("ISO-8859-1"), "gb2312");是什么意思?
孟子E章 2004-05-10
  • 打赏
  • 举报
回复
sp显示的中文是乱码

应在第一行加上
<%@ page contentType="text/html;encoding=gb2312" %>

如果是请求参数为中文,则需要转码。方法如下:
String aParam = request.getParameter("aParam");
if (aParam == null)
aParam = "";
aParam = new String(aParam.getBytes("ISO-8859-1"), "gb2312");

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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