1 现象
浏览器客户端页面charset是GBK
<Meta http-equiv="content-type" content="text/html; charset=GBK" />
服务端收到乱码
String roleName = request.getParameter(ROLE_NAME_PARAM);
String charset = request.getCharacterEncoding();
jQuery.ajax({
url: path,type: "POST",dataType:'json',contentType: "application/x-www-form-urlencoded; charset=utf-8",// 增加这一行
data:{'type' : type,'roleName' : roleName,'roleId' : roleId},success:function(json) {
},error:function(er){
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});
原文链接:https://www.f2er.com/ajax/165591.html