在Spring项目上工作,我正在学习使用Spring Security.该项目正在运作,但突然决定不这样做.任何人都可以解释为什么?
WebInit.java
package com.catalyst.Config;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
public class WebInit implements WebApplicationInitializer
{
@Override
public void onStartup(ServletContext servletContext) throws ServletException
{
Dynamic hServlet;
AnnotationConfigWebApplicationContext hAnnoCTX;
hAnnoCTX = new AnnotationConfigWebApplicationContext();
hAnnoCTX.register(WebMVCConfig.class);
hAnnoCTX.setServletContext(servletContext);
hServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(hAnnoCTX));
hServlet.addMapping("/");
hServlet.setLoadOnStartup(1);
}
}Run Code Online (Sandbox Code Playgroud)
WebMVCConfig.java
package com.catalyst.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
@Configuration
@ComponentScan("com.catalyst")
@EnableWebMvc
public class WebMVCConfig extends WebMvcConfigurerAdapter
{
@Bean
public …Run Code Online (Sandbox Code Playgroud)