其他分享
首页 > 其他分享> > The valid characters are defined in RFC 7230 and RFC 3986

The valid characters are defined in RFC 7230 and RFC 3986

作者:互联网

问题: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");

问题解决~

标签:roomName,characters,defined,RFC,url,startTime,7230,3986
来源: https://www.cnblogs.com/penghq/p/14892863.html