I am trying to convert a web.xml based web app to spring boot but am having trouble configuring an HttpRequestHandlerServlet. I have the following in my web.xml:
<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>
The 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't figure out how to configure updateServlet.
How does one configure an HttpRequestHandlerServlet based servlet in a Spring Boot application?
Additional Info:
I tried the suggested answer but it doesn't work for me.
One thing that I didn't mention is that UpdateServlet is named "updateServlet": Componenet("updateServlet") public class UpdateServlet implements HttpRequestHandler
That name conflicts with the bean name in the answer. After changing it (to update), 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]