默认情况下使用Spring安全性
StrictHttpFirewall
拒绝任何可疑的HTTP请求。如果URL包含字符序列,它将认为该URL可疑
//
关于它需要这样做的原因以及它试图防止的攻击,您可以参考
this
,
this
,
this
和
this
了解更多信息。
第一种选择是四处玩耍
StrictHttp防火墙
并查看其设置是否允许进行配置以满足您的需求:
public class Config extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
StrictHttpFirewall firewall = new StrictHttpFirewall();
//configure the firewall instance....
web.httpFirewall(firewall);
}
}
第二种选择是使用安全性较低的
HttpFirewall
它被称为
DefaultHttpFirewall
(尽管它的名字是
默认Http防火墙
,它不是自弹簧安全性4.2.4以来的实际默认值:P)。使用风险自负。
public class Config extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.httpFirewall(new DefaultHttpFirewall());
}
}