1、是自己继承HttpServlet。

那么在类上面加

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

就可以了

springboot添加servlet的两种方法

 

 

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

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

springboot添加servlet的两种方法

 

相关文章: