我试图配置spring以允许URL中的编码斜杠,但我无法获得要应用的配置
我已经尝试添加@EnableWebSecurity但它似乎没有改变任何东西。当我放置断点时,调用@Bean方法但不调用configure()。
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Bean
public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
DefaultHttpFirewall firewall = new DefaultHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
return firewall;
}
@Override
public void configure(WebSecurity web) throws Exception {
web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
}
}
我设法使用xml配置使其工作。我在applicationContext.xml中添加了以下内容:
<bean id="allowUrlEncodedSlashHttpFirewall"
class="org.springframework.security.web.firewall.DefaultHttpFirewall">
<property name="allowUrlEncodedSlash" value="true"/>
</bean>
<security:http-firewall ref="allowUrlEncodedSlashHttpFirewall"/>