问题:IE11下请求报错
上面的图片中,我们明确看到这样一行Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986,这句话的大致意思就是说请求头中包含了 RFC 7230 and RFC 3986规范中定义的非法字符。在这种情况下就会导致页面报400异常。
引发问题代码:
var url = "/pcms/booking/init.do?startTime=" + startTime + "&roomId=" + roomid+"&roomName="+roomName; window.location.href = url;
其中roomName是中文。
解决问题:
在前端对前端URL进行编码,后台进行解码。
var url = "/pcms/booking/init.do?startTime=" + startTime + "&roomId=" + roomid+"&roomName="+encodeURI(encodeURI(roomName)); window.location.href = url;
roomName = URLDecoder.decode(roomName,"utf-8");
问题解决~