您的位置:首页 > 编程语言 > Java开发

Java代码中使用response.redirect(url)方法,无法获取到中文的解决方法

2014-11-04 14:06 453 查看
今天在项目中碰到这中文问题,特记下来Mark下:

一、获取中文参数时,先编码。如:

String productPara = request.getParameter("productPara");//这是“中文参数”

然后编码:

productPara = URLEncoder.encode(productPara,"utf-8");

return "redirect:/user?productPara='"+productPara;

在接收时再进行转码,

new String(request.getParameter("productPara").getBytes("ISO-8859-1"), "UTF-8");

这样就可以正确得到传送过来的中文参数。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐