23 lines
874 B
Java
23 lines
874 B
Java
package com.ycjy;
|
|
|
|
import com.ycjy.config.AppConfig;
|
|
import jakarta.servlet.ServletContext;
|
|
import jakarta.servlet.ServletException;
|
|
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 context = new AnnotationConfigWebApplicationContext();
|
|
context.register(AppConfig.class); // 登记表
|
|
context.setServletContext(servletContext);
|
|
context.refresh();
|
|
|
|
servletContext
|
|
.addServlet("dispatcherServlet", new DispatcherServlet(context))
|
|
.addMapping("/");
|
|
}
|
|
}
|