我有一个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/