我想结合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/*
- webservice -
localhost:8080/web/*
- MVC组件
提前致谢!
1 回答
问题在于注册
MessageDispatcherServlet
由于名称dispatcherServlet
它覆盖了Spring Boot注册的DispatcherServlet
. 后者是您网站的MVC部分所必需的 .要修复它,只需将您的方法重命名为
dispatcherServlet
说messageDispatcherServlet
.