校验 , 全局异常处理
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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("/");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user