在 <display:table> 标签中使用 Struts2 的 <s:property> 标签

Use Struts2's <s:property> tag in <display:table> tags

我正在尝试使用 DisplayTag 将列表添加到 table。

当我以通常的方式将列表 属性 添加到列时,一切正常:

<display:column property="status" title="Claim Status"/>
<display:column property="authNo" title="Authorization Number" href="authSlipMasterAction">

现在,我想检查 authNo 何时不为空;如果它是空白的,那么不要提供 link,那么我如何在 <display:table> 标签中使用 <s:if test=''><s:property value="">

我尝试使用 <s:property value="authNo"/> 显示值,但没有显示值(我必须显示值,因为我想检查条件)

这是我的代码

   <display:table uid="myTable" id="display-tag" name="session.claimReportList">
   <display:column title="Authorization No"> 
    <s:property value="#attr.myTable.transNo" />
</display:column>

我也试过

      <s:property value="#session.myTable.transNo" />

在 DisplayTag 列中,您需要在 <s:property /><s:if /> 中使用 #attr. 符号;您还需要 use the uid specified in the <display:table> tag after the #attr. 才能访问您的对象。

例如:

<display:table requestURI="actionURL" uid="myTable" />

    <display:column title="authNo">    
        <s:property value="#attr.myTable.authNo" />
    </display:column>

</display:table>

来自 OGNL Basics - Struts 2 Named Objects:

#attr['foo'] or #attr.foo

Access to PageContext if available, otherwise searches request/session/application respectively

P.S:不过,我会考虑看一些较新的网格,例如 jqGrid or DataTables

请在显示标签内尝试以下代码。

1.) #attr.objectName: 页面、请求、会话或应用程序范围内的属性(按顺序搜索)
2.) row 是您用于 display:table.
id 3.) authNo:您的自定义 属性。

<s:if test="%{#attr.row.authNo != null}">
    <display:column title="Status">Your custom message</display:column>
    </s:if>

希望对您有所帮助..!!