还是乱码问题--js传参数乱码

来源:互联网 发布:淘宝双11如何报名 编辑:程序博客网 时间:2024/05/01 19:07

处理js传参数有中文乱码的情况

js编码 :
var comment = document.all.comment.value;
comment = encodeURI(comment );
comment = encodeURI(comment );//注重要两次

action解码
String comment = request.getParameter("comment ");
try {
comment = java.net.URLDecoder.decode(comment, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

原创粉丝点击