问题
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