Apache Tiles If/Else [英] Apache Tiles If/Else

查看:86
本文介绍了Apache Tiles If/Else的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能对Apache Tiles 2(或引用了Tiles属性的JSTL进行if/else处理).基本上,我想要这样:

I am wondering if it's possible to have an if/else with Apache Tiles 2 (or JSTL that references a Tiles attribute, that would work to). Basically, I want this:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<div>
    <!-- Some stuff here -->
</div>
<tiles:if condition="showSecondDiv == 'true'">
    <div>
        <!-- Some second stuff here -->
    </div>
</tiles:if>

Tiles XML中有<put-attribute name="showSecondDiv" value="true" type="string" />.这样做的动机是,我想在许多地方重用此JSP,有些地方想同时显示两个div,另一些地方只想显示一个.

There is <put-attribute name="showSecondDiv" value="true" type="string" /> in the Tiles XML. The motivation is that I want to reuse this JSP in a number of places, some that want to show both divs, others that only want to show one.

推荐答案

使用JSTL
例如:

USING JSTL
example:

     <c:if test="${!empty tilesAdditionalTitle}">
       <fmt:param value="${requestScope[tilesAdditionalTitle]}"  />
     </c:if>

这篇关于Apache Tiles If/Else的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆