How can use if tag in Struts 2?

五迷三道 提交于 2019-12-01 11:59:17

问题


I am really new to Struts2. I have the below Struts2 tag, I need to check if property value="#attr.row.Commentaire is not empty and if it's not, display a small icon where the user can click it and consult the contents of the property value="#attr.row.Commentaire. How can I use the if tag of Struts2 efficiently to do that?

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

回答1:


Use the following code

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

The if tag uses the test attribute to evaluate OGNL expression to a boolean value.

You may also want to use an a tag which renders a HTML anchor tag that could be used combined with the if tag to

consult the contents of the property

There's also a debug tag that could be used to wrap other tags to show you a link that will render a debug data.

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


来源:https://stackoverflow.com/questions/17943974/how-can-use-if-tag-in-struts-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!