首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

urlrewrite 中文件参数乱码有关问题

2013-03-06 
urlrewrite 中文件参数乱码问题请求地址:/search/冒险.html在Action里获取时,是乱码“??”String keyword

urlrewrite 中文件参数乱码问题
请求地址:/search/冒险.html
在Action里获取时,是乱码“??”


String keyword = null == request.getParameter("keyword") ? "" : request.getParameter("keyword");
 keyword = new String(keyword .getBytes("ISO-8859-1"),"utf-8");


这里的keyword打印出来是"??",请问这是什么问题啊,怎么解决啊!
[解决办法]
请求地址改下

例如location.href = "/search/冒险.html";
修改成location.href = encodeURI(""/search/冒险.html"); 
[解决办法]
在传进来之前转码encodeURI
还不行就看看Web容器的server.xml文件中找到Connector节点、加上编码 URIEncoding="UTF-8"

<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"/>

[解决办法]
另一篇贴子已回!加上URIEncoding="UTF-8"是没什么用的!

热点排行
Bad Request.