RequestMapping的一些
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.ycjy;
|
||||
|
||||
import com.ycjy.confing.WebConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRegistration;
|
||||
import org.springframework.web.WebApplicationInitializer;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
public class MyInit implements WebApplicationInitializer {
|
||||
@Override
|
||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
||||
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
|
||||
rootContext.register(WebConfig.class);
|
||||
rootContext.setServletContext(servletContext);
|
||||
rootContext.refresh();
|
||||
|
||||
DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext);
|
||||
ServletRegistration.Dynamic dispatcherServlet1 = servletContext.addServlet("dispatcherServlet", dispatcherServlet);
|
||||
dispatcherServlet1.addMapping("/");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user