前几天遇到这个问题,在网上搜索了很多资料,这里总结一下解决方法:
报错原因:Tomcat在7之后对http请求添加了验证。
解决方案:
1.更换低版本的tomcat
2.在tomcat下的catalina.properties添加org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
3. 在tomcat下的catalina.properties添加 tomcat.util.http.parser.HttpParser.requestTargetAllow=|{} ,其中花括号中填写需要绕过的字符的二进制编码,具体如下所示:
tomcat.util.http.parser.HttpParser.requestTargetAllow=|{32,34}
- 键盘上那些控制键:(
<32或者=127
) - 非英文字符(
>127
) 空格
(32
)双引号
(34
)#
(35
)<
(60
)>
(62
)反斜杠
(92
)^
(94
)TAB键
(96
){
(123
)}
(124
)|
(125
)
官方说明: http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html#Security
4.将所有不允许的字符进行转码