struts多模塊可以加快團隊的開發(fā)節(jié)奏,但實際運用時需要注意以下幾點:
1. 不支持path mapping (/do/*), 也就是說在傳統(tǒng)的單模塊程序中,你可以在地址欄寫上
http://localhost:8080/myApp/index
但在多模塊應(yīng)用程序中,這樣寫是錯的,原因是Struts不知道請求哪個模塊;
所以必須寫成 http://localhost:8080/myApp/index.do
2. module prefix只適用于action, 當(dāng)你要通過struts的某些tag (如html:link)跳轉(zhuǎn)
到不同模塊的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配置文件中指明的跳轉(zhuǎn)到j(luò)sp的url
不是相對于模塊的,而是相對于整個應(yīng)用的。
1. 不支持path mapping (/do/*), 也就是說在傳統(tǒng)的單模塊程序中,你可以在地址欄寫上
http://localhost:8080/myApp/index
但在多模塊應(yīng)用程序中,這樣寫是錯的,原因是Struts不知道請求哪個模塊;
所以必須寫成 http://localhost:8080/myApp/index.do
2. module prefix只適用于action, 當(dāng)你要通過struts的某些tag (如html:link)跳轉(zhuǎn)
到不同模塊的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配置文件中指明的跳轉(zhuǎn)到j(luò)sp的url
不是相對于模塊的,而是相對于整個應(yīng)用的。