今天遇到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");