我想在我的struts2配置中添加命名空間,並使用瓦片。對瓦片使用多個Struts2命名空間
A爲例包我的struts.xml的:
<package name="search" namespace="/search" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="SearchActionInit" class="web.action.SearchAction" method="initSearch">
<result name="input" type="tiles">search</result>
<result name="success" type="tiles">search</result>
</action>
</package>
而相應區塊配置:
<definition name="baseLayout" template="layout.jsp">
<put-attribute name="titre" value="titre.default" />
<put-attribute name="header" value="/common/header.jsp" />
<put-attribute name="menu" value="/common/menu.jsp" />
<put-attribute name="leftcontent" value="/common/leftcontent.jsp" />
<put-attribute name="rightcontent" value="/common/rightcontent.jsp" />
<put-attribute name="detail" value="/common/detail.jsp" />
<put-attribute name="footer" value="/common/footer.jsp" />
</definition>
<definition name="search" extends="baseLayout">
<put-attribute name="titre" value="titre.search" />
<put-attribute name="rightcontent" value="/pages/search/Search.jsp" />
</definition>
我的問題是,我需要複製在該layout.jsp搜索文件夾以進行名稱空間搜索(對於其他名稱空間等)。這不是在瓷磚邏輯中,並會帶來更多的努力來維護。
有沒有人對這個問題的關鍵,以避免重複?
嗨,我不明白,爲什麼你必須重複layout.jsp。你不必定義'result-types',試試這個:' ' –
Jaiwo99
Thx for your answer。添加tiles-default沒有變化。我需要複製它,因爲他正在與名稱空間名稱相同的文件夾中等待layout.jsp。例如在這個例子中,我重命名了layout.jsp,並得到了一個404錯誤(找不到search/layout.jsp)。 – Rydermark
我終於明白你的問題了。我稍後會給你答案.. – Jaiwo99