I am trying to convert a web.xml based web application to boot spring, but I am having trouble setting up the HttpRequestHandlerServlet. In my web.xml, I have the following:
<servlet> <servlet-name>webServices</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>updateServlet</servlet-name> <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>updateServlet</servlet-name> <url-pattern>/update</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>webServices</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping>
DispatcherServlet was not a problem:
@SpringBootApplication public class WebApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(PoolWebApplication.class); } @Bean public DispatcherServlet dispatcherServlet() { return new DispatcherServlet(); } @Bean public ServletRegistrationBean servletRegistrationBean() { return new ServletRegistrationBean(dispatcherServlet(), "/ws/*"); } }
But I can not figure out how to configure updateServlet.
How to configure servlet in HttpRequestHandlerServlet in spring boot application?
Additional Information:
I tried the suggested answer, but it does not work for me.
One thing that I haven't mentioned is that the UpdateServlet is called "updateServlet": Componenet ("updateServlet") The public UpdateServlet class implements the HttpRequestHandler
This name conflicts with the name bean in the response. After changing it (for updating) I get:
No bean named 'httpRequestHandlerServlet' is defined
After changing the name of updateServlet to httpRequestHandlerServlet I get
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'httpRequestHandlerServlet' must be of type [org.springframework.web.HttpRequestHandler], but was actually of type [org.springframework.web.context.support.HttpRequestHandlerServlet]
java spring spring-boot spring-mvc
Dan ciarniello
source share