The request was rejected because the URL contained a potentially malicious String “//“

解决方案

  • 把多余的/去掉就好了。

  • 但我疑惑的是为什么php就可以,java报错了,后来查到是Spring Security拦截了。

  • 源代码在StrictHttpFirewall#setAllowUrlEncodedDoubleSlash

  • 这个类里面其他的方法应该也和特殊字符有关(如setAllowBackSlash、setAllowUrlEncodedPercent等)。

  • 重新注入StrictHttpFirewall对象,就可以让它支持//的模式。

    /**
     * 配置地址栏不能识别 // 的情况
     * @return
     */
    @Bean
    public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
        StrictHttpFirewall firewall = new StrictHttpFirewall();
        //此处可添加别的规则,目前只设置 允许双 //
        firewall.setAllowUrlEncodedDoubleSlash(true);
        return firewall;
    }
  • 这样就能成功了,结果如下图所示。

The request was rejected because the URL contained a potentially malicious String “//“报错详情org.springframework.security.web.firewall.RequestRejectedException:TherequestwasrejectedbecausetheURLcontainedapotentiallymaliciousString“//”atorg.springframework.security.web.firewall.StrictHttpFirewall.rejectedBlacklistedUrlshttps://www.icode9.com/content-4-1325735.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值