使用MVC的Spring Boot SOAP Web服务

Jareks

我想结合Spring指南中的两个Spring(spring-boot)应用程序:

不幸的是,这些示例不能一起使用。servlet调度程序存在问题。添加dispatcherServlet bean之后-MVC Servlet无法正常工作(错误404)。

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

如何配置servlet调度程序以使其正常工作?

我想拥有:

  • localhost:8080/ws/* - 网络服务
  • localhost:8080/web/* -MVC组件

提前致谢!

然后马库斯

问题在于的注册,MessageDispatcherServlet因为dispatcherServlet它覆盖了Spring Boot注册的名称DispatcherServlet网站的MVC部分需要后者。

要解决该问题,只需将您的方法重命名为除了dispatcherServletsay之外的任何内容messageDispatcherServlet

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章