关于在 url 里面传递 中文 字符的乱码问题。str = "我是一个猪";
url = 'webmail-busicardedit.do?parm1='str;
window.location.href = url;然后跑到下一个画面 接受到的 str 就是乱码了。请问我如何实现转码啊?URLEncoder.encode或者encodeURI到底怎么用啊?有没有人能说得具体一点啊。谢谢了
url = 'webmail-busicardedit.do?parm1='str;
window.location.href = url;然后跑到下一个画面 接受到的 str 就是乱码了。请问我如何实现转码啊?URLEncoder.encode或者encodeURI到底怎么用啊?有没有人能说得具体一点啊。谢谢了
try {
if (str == null) {
str = "";
} else {
str = new String(str.getBytes("GBK"), "ISO-8859-1");
}
} catch (Exception e) {
System.out.println("DealString::toGBK(String)运行时出错:错误为:" + e);
}
return str;
}///
/** 转换编码 */
public String toGBK(String str) {
try {
if (str == null) {
str = "";
} else {
str = new String(str.getBytes("ISO-8859-1"), "GBK");
}
} catch (Exception e) {
System.out.println("DealString::toGBK(String)运行时出错:错误为:" + e);
}
return str;
}
------------
这个连接我发了3,4次了。
希望对你有帮助。
url = 'webmail-busicardedit.do?parm1='+str; //你少写了个+
window.location.href = url;