前端请求导出数据,带参,报400错误

400是后端没有接收到请求,原因是后端高版本的tomcat不会自动对字符串进行转义。

所以,前端把参数值进行转义即可。

encodeURI(string);

eg:

window.location.href = hostAndPort.HOST+hostAndPort.PORT +
baseUrl+'/eventTrack/exportLoginData?fromDate='+this.dateInfo.start+"&toDate="+
this.dateInfo.end+"&token="+encodeURI(localStorage.getItem('token'));
posted @ 2018-01-17 10:19  coconutGirl  阅读(1252)  评论(0编辑  收藏  举报