Maven 可以将公共控制器、jsp 和其他资源共享给 web 模块。
结构
web1(包装罐)
--main
--java
--controller
MyControllerToShared with @Controller annotation
--resources
--webapp
--scripts
javascripts files
--styles
css files
--WEB-INF
--views
jsp to share
pom.xml
web2(包装大战)
Classic web app structure with dependency of web1.jar
我的 web2 应用程序可以工作,但没有找到在 web1 模块中定义 URI 的 HTTP 请求的映射。我使用注解@Controller 和@RequestMapping。我在 servlet.xml 中定义:
<context:component-scan base-package="controller" />
<mvc:annotation-driven/>
如何在不同的 Web 模块之间共享控制器和资源?最后,我需要有 3 个带有公共内容的 Web 应用程序(错误处理程序、jsp 的错误、样式、js ......)。