How can I register a secondary servlet with Spring Boot?

后端 未结 7 687
感动是毒
感动是毒 2020-11-30 19:29

I have an extra servlet I need to register in my application. However with Spring Boot and its Java Config, I can\'t just add servlet mappings in a web.xml file

7条回答
  •  遥遥无期
    2020-11-30 20:12

    Also available is the ServletRegistrationBean

    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        return new ServletRegistrationBean(new FooServlet(),"/someOtherUrl/*");
    }
    

    Which ended up being the path I took.

提交回复
热议问题