url地址参数如果是日文的话,读取后有乱码

theoffspring 2006-03-14 04:22:58
我在a页面重定向到b页面,地址参数是一段日文,在b页面读取这个参数值的时候,有乱码,不知怎么解决
a.jsp:
<%@ page contentType="text/html; charset=euc-jp" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp" />
<title>Untitled Document</title>
</head>

<body>
<a href="b.jsp">click
</a>
</body>
</html>
<%
response.sendRedirect("http://127.0.01:8080/onestop/search/b.jsp?url="+java.net
.URLEncoder.encode("あ い う え ","MS932"));

%>

b.jsp:
<%@ page contentType="text/html; charset=euc-jp" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>
<%=java.net.URLDecoder.decode(request.getParameter("url"),"MS932")%>
...全文
432 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
theoffspring 2006-03-22
  • 打赏
  • 举报
回复
ding
theoffspring 2006-03-21
  • 打赏
  • 举报
回复
ding
theoffspring 2006-03-20
  • 打赏
  • 举报
回复
ie默认是UTF-8吧
believefym 2006-03-20
  • 打赏
  • 举报
回复
我发现读取参数的时候,如果new String(str.getBytes("iso-8859-1"),"euc_jp")就能正确编码,在传递参数的时候甚至不用编码,iso-8859-1不是欧洲字符集吗,怎么可以解析日文呢。
----------------
因为web页面就是默认通过iso8859-1编码传的
theoffspring 2006-03-20
  • 打赏
  • 举报
回复
dign
theoffspring 2006-03-19
  • 打赏
  • 举报
回复
怎么改啊
theoffspring 2006-03-19
  • 打赏
  • 举报
回复
顶一下
numen_wlm 2006-03-18
  • 打赏
  • 举报
回复
修改tomcat的server.xml文件
theoffspring 2006-03-18
  • 打赏
  • 举报
回复
但是某些字符仍然是乱码啊,比如全角的减号
theoffspring 2006-03-17
  • 打赏
  • 举报
回复
up
theoffspring 2006-03-16
  • 打赏
  • 举报
回复
我发现读取参数的时候,如果new String(str.getBytes("iso-8859-1"),"euc_jp")就能正确编码,在传递参数的时候甚至不用编码,iso-8859-1不是欧洲字符集吗,怎么可以解析日文呢。
theoffspring 2006-03-15
  • 打赏
  • 举报
回复
抗日不是这么的,来这里的程序员至少有80%是做对日的
joe_wuyy 2006-03-15
  • 打赏
  • 举报
回复
抗日
theoffspring 2006-03-15
  • 打赏
  • 举报
回复
up
chengxuyuan711 2006-03-15
  • 打赏
  • 举报
回复
仅供参考,呵呵
chengxuyuan711 2006-03-15
  • 打赏
  • 举报
回复
刚看到个类似的帖子,如果你的服务器是TOMCAT的话
在 Tomcat 的 Server.xml 配置中,通过 GET 传送的 ?a=xxxxxx 这种 url 的编码是可以单独配置的(URIEncoding)
螃蟹k3179 2006-03-14
  • 打赏
  • 举报
回复
地址日货

81,122

社区成员

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

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