package zti.web; 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 WebServlet implements WebApplicationInitializer { public void onStartup(ServletContext ctx) throws ServletException { AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext(); webCtx.register(WebConfig.class); webCtx.setServletContext(ctx); ServletRegistration.Dynamic servlet = ctx.addServlet("dispatcher", new DispatcherServlet(webCtx)); servlet.setLoadOnStartup(1); servlet.addMapping("/"); } }