RequestMapping的一些

This commit is contained in:
2026-10-23 11:30:29 +08:00
parent 62db69214e
commit cd3538f10e
5 changed files with 191 additions and 0 deletions
@@ -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("/");
}
}