在关于Spring Security for a web(MVC)应用程序[1]的参考文章之后,我发现自己必须实现这样一个类:
package com.my.web.config;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class MySecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
}
仅仅有一些注释来完成这项工作会不会更容易?像我们已经拥有的所有@EnableXXX一样?
或覆盖网络应用初始值设定项中的注册方法,就像我有:
public class MyWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { MyWebAppConfig.class, MyDataConfig.class, MyWebSecurityConfig.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
protected Filter[] getServletFilters() {
return new Filter[] { new CharacterEncodingFilter(CharEncoding.UTF_8) };
}
}