我有一个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 for row如果actioned属性不超过6个月,那么隐藏它,有人可以帮忙如何继续吗?
答案 0 :(得分:1)
在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>