post请求 过滤器 encodeURI未解决!! 使用contentType也于事无补
测试环境1:ajax带参请求:name
get/post 无变化
前台:直接传递name(值可获取)
后台:解码/不解 效果一致
当参数nam值通过浏览器ajax request请求到后台不为
application/x-www-form-urlencoded MIME 值
效果与编码一致
浏览器的request请求值为application/x-www-form-urlencoded MIME
request 200
个人考虑:前台与后台编码不一致
前端:
data() {
var name=this.$route.query.name;
$.ajax({
url : 'topInfo?name='+name,
contentType: "application/json; charset=utf-8",
type : 'POST', //GET
async : false, //或false,是否异步
//timeout : 5000, //超时时间
dataType : 'json', //返回的数据格式:
success : function(data) {
this.items = data.data;
},
error : function(data) {
alert("失败!!");
}
})
debugger;
return {
items
}
},
后台:
public void moreList() throws Exception
{
if("".equals(name)||name==null){
SessionUtils.outRightJSon(this.response,"--null--");
} else if(name.equals("%E5%91%A8%E8%80%81%E5%B8%88")){
SessionUtils.outRightJSon(this.response,"--周老师--");
}
//URLDecoder.decode(name,"UTF-8")
request.setCharacterEncoding("utf-8");
ContentVO listContentVo = topServiceImpl.more(name,5);
SessionUtils.outRightJSon(this.response, listContentVo);
}