java - 如何在 JSP 中基于另一个属性显示一个属性

标签 java jsp jstl

我有一个jsp,其中显示了一个类似的表格

<tr class="even">                
<td><bean:write name="itemDetails" property="recived"/></td>                                         
<td><bean:write name="itemDetails" property="actioned"/></td>
<td> <bean:write name="itemDetails" property="internalUser"/></td> 
<td> <bean:write name="itemDetails" property="action"/>   </td>
 </tr>  </logic:iterate>

这里操作的属性是日期,格式为 08/05/2014 14:34

现在我想显示行的属性internalUser,如果操作的属性不超过6个月,否则隐藏它,任何人都可以帮助如何继续吗?

最佳答案

例如,在 itemDetails 中创建另一个属性

private boolean showInternalUser;

public boolean getShowInternalUser() {
   // compare difference between `actioned time` and `new Date()` here (6 months)
   // and return true if you need to display the property `internalUser`
}

public void setShowInternalUser(boolean showInternalUser) {
   this.showInternalUser = showInternalUser;
}

然后在jsp中更改:

<td> <bean:write name="itemDetails" property="internalUser"/></td> 

<td>
   <c:if test="${itemDetails.showInternalUser}">
      <c:out value="${itemDetails.internalUser}"/>
   </c:if>
</td>

关于java - 如何在 JSP 中基于另一个属性显示一个属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23544336/

相关文章:

java - jquery datatables 未加载表数据

jsf-2 - <c :if> Tag does not reduce the component tree in composite components

spring - 如何格式化 LocalDateTime 以将其呈现在 JSP View 中

javascript - Vue.js 组件在 jsp 文件中不起作用

java - 在jsp中添加请求参数

从 Struts2 操作标签调用操作时出现 java.lang.StackOverflowError

java - 在java中登录多线程应用程序

java - GraalVM 和 Jvm-Hotspot 的区别

java - 如何识别哪些消息成功发布到kafka主题以及哪些消息失败

jsp - 基本身份验证 : Is it possible to setRemoteUser like getRemoteUser()