Spring 5.0.3 抛出错误The request was rejected because the URL was not normalized
2018-03-08 20:10:33
4893次阅读
0个评论
升级Spring 5.0.3和Spring security-5.0.3 后出现错误The request was rejected because the URL was not normalized.
原因是访问路径目录中出现http://127.0.0.1/xxx//xx 这样访问,新版本Spring将默认不允许使用//
解决办法一是将//这种路径删除
解决办法二
使用自定义的StrictHttpFirewall实现来替换默认的spring security 实现
@Bean
public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
StrictHttpFirewall firewall = new StrictHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
firewall.setAllowSemicolon(true);
return firewall;
}
然后在WebSecurity中配置这个bean
@Override
public void configure(WebSecurity web) throws Exception {
super.configure(web);
// @formatter:off
web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
...
}
00
相关话题
- Nginx 上传文件出现413 Request Entity Too Large错误
- SpringMVC获取Request域
- Nginx 根据URL请求参数转发
- Nginx根据URL实现负载均衡
- commons-lang3提示“The type StringEscapeUtils is deprecated”
- lucene (Too many open files)错误
- MyEclipse启动发生"An error has occurred.See the log file "解决
- 获取SpringMVC中所有的RequestMapping映射URL地址
- Spring下载地址
- Spring常用注解
- java.lang.ClassNotFoundException: javax.xml.bind.JAXBException错误
- Spring MVC 文件下载
- spring boot集成Hibernate配置
- Spring 自带工具类
- 解决一个意外错误使您无法删除该文件