繁体   English   中英

怎么用<s:if> Struts 2 中的标签?

[英]How can use <s:if> tag in Struts 2?

我有下面的 Struts 2 标签,我需要检查 property value="#attr.row.Commentaire是否不为空,如果不是,则显示一个小图标,用户可以在其中单击它并查阅属性value="#attr.row.Commentaire的内容value="#attr.row.Commentaire .

我怎样才能有效地使用 Struts 2 的<s:if>标签来做到这一点?

<display:column title="Commentaire" sortable="true" sortProperty="Commentaire"
    class="alerte_td_commentaire">              
<s:property value="#attr.row.Commentaire"/>

使用以下代码

<s:if test="#attr.row.Commentaire != null && #attr.row.Commentaire != ''">

if标签使用test属性将OGNL表达式计算为布尔值。

您可能还想使用a标签来呈现一个 HTML 锚标签,该标签可以与if标签结合使用

查阅财产内容

还有一个debug标记,可用于包装其他标记以向您显示将呈现调试数据的链接。

<s:debug>  
 <s:property value="%{#attr.row.Commentaire}"/>
</s:debug>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM