我正在尝试将 Spring 应用程序迁移到 Spring Boot。在 tomcat 服务器上运行应用程序时,出现以下错误:
由于 URL 未规范化,请求被拒绝。
我尝试在我的入口点类中添加以下 bean 来解决错误。
@Bean
public InternalResourceViewResolver jspViewResolver() {
InternalResourceViewResolver bean = new InternalResourceViewResolver();
bean.setPrefix("/WEB-INF/ui/");
bean.setSuffix(".jsp");
return bean;
}
@Bean
public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
StrictHttpFirewall firewall = new StrictHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
return firewall;
}
@Bean
public StrictHttpFirewall httpFirewall() {
StrictHttpFirewall firewall = new StrictHttpFirewall();
firewall.setAllowSemicolon(true);
return firewall;
}
@Bean
public HttpFirewall defaultHttpFirewall() {
return new DefaultHttpFirewall();
}
public void configure(WebSecurity web) throws Exception {
web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
}
Run Code Online (Sandbox Code Playgroud)
错误日志:
org.springframework.security.web.firewall.RequestRejectedException: The request was rejected …
Run Code Online (Sandbox Code Playgroud)