ServletRegistrationBean不适用于多个URL映射路径 [英] ServletRegistrationBean doesn't works for the multiple URL mapping paths

查看:2275
本文介绍了ServletRegistrationBean不适用于多个URL映射路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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/*");
}

收件人

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

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

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

推荐答案

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

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

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

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

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

Spring Boot日志,WSDL 肥皂请求响应

Spring Boot Log, WSDL Soap Request Response

不确定什么不适用于您. 当我们执行/service/*网址时,以下配置不起作用."

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

这篇关于ServletRegistrationBean不适用于多个URL映射路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆