springboot添加servlet的两种方法

1、是自己继承HttpServlet。

那么在类上面加

@WebServlet(loadOnStartup=1,urlPatterns={"/xxxServlet"})

就可以了

2、在启动类或者是配置类中添加Bean

@Bean
public ServletRegistrationBean servletTLReportServlet() {
    return new ServletRegistrationBean(new TLReportServlet(), "/tlreport/*");
}

原文地址:https://www.cnblogs.com/xiaostudy/p/11385385.html