ServletRegistrationBean 不适用于多个 URL 映射路径

ServletRegistrationBean doesn't works for the multiple URL mapping paths

我正在开发查看 https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/ 的代码,在下面的 bean 中,我想允许对 /*/service/* 执行请求,所以我更改为

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

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

当我们执行 /service/* url 时,以下配置不起作用。我们该如何解决这个问题?

映射对我有用。我下载了示例并根据您的问题进行了更改。

我看到注册的映射(日志)和加载的 wsdl(浏览器),如屏幕截图所示。

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

Spring 引导日志,WSDL Soap 请求响应

不确定什么不适合您。 "Below configurations doesn't works when we execute the /service/* url."