response.sendRedirect()中文参数乱码问题

[复制链接]
查看11 | 回复3 | 2005-5-23 13:53:00 | 显示全部楼层 |阅读模式
我想用response.sendRedirect(request.getContextPath()+"/err.jsp?err=数据类型不正确&quot

在转向另一页的同时,传递参数err.但是在jsp页面中得到的是乱码
err.jsp页面中接受代码

String str=new String(request.getParameter("err&quot

.getBytes("ISO-8859-1&quot

,"GBK&quot

;
out.println(str);
jsp页面的
服务器是Oracle IAS 10g
怎么解决?
回复

使用道具 举报

千问 | 2005-5-23 13:53:00 | 显示全部楼层
请使用这个来对进行编码:java.net.URLEncoder
回复

使用道具 举报

千问 | 2005-5-23 13:53:00 | 显示全部楼层
String str=URLEncoder.encode("数据类型不正确&quot

;
response.sendRedirect(request.getContextPath()+"/err.jsp?err="+str);
我用上面的方法试过,可还是不行呀
有没有什么好的方法啊
回复

使用道具 举报

千问 | 2005-5-23 13:53:00 | 显示全部楼层
你还是不要这样手动的转码比较好
开始时,马上设置request的编码格式:
request.setCharacterEncoding("编码&quot

然后再获取参数
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行