日期:2014-05-18  浏览次数:20742 次

跟大家分享一下,json中文传值问题。
今天遇到json中文传值问题,鼓捣了好久,终于弄好了。跟大家分享一下。
url="<%=path%>/auth/checkTheUsername.pop?username="+encodeURIComponent(encodeURIComponent($(this).val()));
$.getJSON(url,function(data){
if(data.cunzai=='yes'){
$("#userexit").html("该账户已经存在");
}else
$("#userexit").html("");
});

注意红色部分是转码代码。

在java代码中,在转码就可以了
String userString=java.net.URLDecoder.decode(username,"utf-8");


------解决方案--------------------
恩啊,学习了,谢谢分享。