校验 , 全局异常处理

This commit is contained in:
2026-10-28 10:11:55 +08:00
parent 0b97e86d59
commit f58eafd10a
8 changed files with 170 additions and 0 deletions
@@ -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("/");
}
}