ServletRegistrationBean doesn't works for the multiple URL mapping paths

你说的曾经没有我的故事 提交于 2020-06-23 03:45:41

问题


I was developing code looking at https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/, In the below bean I want to allow request to be executed for /* and /service/*, so I changed to

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext){
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/service/*");
}

To

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext){
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/*","/service/*");
}

Below configurations doesn't works when we execute the /service/* url. How can we fixed this ?


回答1:


The mapping works for me. I downloaded the example and made changes as per your question.

I see the mappings registered(log) and the wsdl(browser) loaded as shown in the screenshot.

Mapping servlet: 'messageDispatcherServlet' to [/*, /service/*]

Spring Boot Log, WSDL Soap Request Response

Not sure what's not working for you. "Below configurations doesn't works when we execute the /service/* url."



来源:https://stackoverflow.com/questions/62081712/servletregistrationbean-doesnt-works-for-the-multiple-url-mapping-paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!