我在所有页面中都有一个共同的标题,除了某些页面,其中有一些选项的标题的右侧。例如,我的标题的右侧将具有以下选项:块,撰写,编辑取决于页面。可以从tiles-config.xml中设置此headerShowIcons,然后在rhsHeader.jsp中使用它。Apache Tiles 2.2.2将tiles-config.xml传递给JSP
有没有什么办法让我可以通过从瓷砖-config.xml中rhsHeader.jsp一些值,并基于该值我想要显示的选项(即阻止,编辑或删除)
示例:如果我想向用户显示Compose选项,我只需从tiles-config.xml传递值(即headerShowIcons ='compose')并在JSP中使用它。如果我想要显示Block,我将传递headerShowIcons ='block',它将被rhsHeader.jsp读取以显示Block选项。我希望这将是更清晰
瓷砖-config.xml中
<definition name="*/*/*/*/*/index" template="/{1}/{2}/xyz/{4}/layouts/layout.jsp">
<put-attribute name="lhsHeader" value="/{1}/{2}/xyz/s/headerWithBack.jsp" />
<put-attribute name="rhsHeader" value="/{1}/{2}/xyz/s/rhsHeader.jsp"/>
<put-attribute name="body" value="/{1}/{2}/xyz/s/myProfile.jsp" />
</definition>
layout.jsp
<!-- What should I add here to meet the requirement -->
<body>
<header>
<div>
<tiles:insertAttribute name="header"/>
<tiles:insertAttribute name="rhsHeader"/>
</div>
</header>
<div>
<tiles:insertAttribute name="body"/>
</div>
</body>
rhsHeader.jsp是这样的:
<tiles:useAttribute name="headerShowIcons" />
<div class="RHS">
<ul>
<!-- I want to show the options (like- Block,Delete,etc) which will be passed from tiles-config.xml to rhsHeader.jsp (which here I have written it as headerShowIcons)-->
<c:choose>
<c:when test="${headerShowIcons eq 'refine'}">
<li><a href="#" class="refine">Refine</a></li>
</c:when>
<c:when test="${headerShowIcons eq 'block'}">
<li><a href="#" class="block">Block</a></li>
</c:when>
<c:when test="${headerShowIcons eq 'edit'}">
<li><a href="javaScript:void(0);" class="edit">Edit</a></li>
</c:when>
<c:when test="${headerShowIcons eq 'delete'}">
<li><a href="javaScript:void(0);" class="delete">Delete</a></li>
</c:when>
<c:otherwise>
<p>test</p>
</c:otherwise>
</c:choose>
</ul>
我已经编辑了问题,我想这会更清楚了。 –
@ balboa_21看到更新回答 – QGA
请看问题的大胆部分。[有什么办法吗?] –