- Hands-On Spring Security 5 for Reactive Applications
- Tomcy John
- 97字
- 2021-07-23 18:59:22
Step 7—Spring MVC setup
In Spring MVC, the request lands on DispatcherServlet. DispatcherServlet can be declared in web.xml or as a Java configuration if your servlet container is 3.0+. Please create a dummy SpringSecurityConfig.java file. We will be constructing this class when we explain the first authentication mechanism, namely, basic authentication:
public class SpringMvcWebApplicationInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { ApplicationConfig.class, SpringSecurityConfig.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { WebApplicationConfig.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}