struts多模块可以加快团队的开发节奏,但实际运用时需要注意以下几点:
1. 不支持path mapping (/do/*), 也就是说在传统的单模块程序中,你可以在地址栏写上
http://localhost:8080/myApp/index
但在多模块应用程序中,这样写是错的,原因是Struts不知道请求哪个模块;
所以必须写成 http://localhost:8080/myApp/index.do
2. module prefix只适用于action, 当你要通过struts的某些tag (如html:link)跳转
到不同模块的jsp时,就要用到SwitchAction
fx: 在一个模块配置文件中写上: < action path="/switchMod"
type="org.apache.struts.actions.SwitchAction"/>
然后象这样使用: < html:link action="/switchMod prefix=/moduleA&page=/moduleA/main.jsp">
ModuleA main JSP
< /html:link>
3. 由于module prefix只适用于action, 所以在tiles配置文件中指明的跳转到jsp的url
不是相对于模块的,而是相对于整个应用的。
责任编辑:小草