我想检查一个对象是否是一个类,并且如果它是一个日期则进行一些格式化。我该如何设置if
条件?
<table align="center" class="data_extract vert_scroll_table" >
<tr>
<c:forEach var="heading" items="${results.headings}">
<th class="data_extract">${heading}</th>
</c:forEach>
</tr>
<c:forEach var="row" items="${results.data}">
<tr>
<c:forEach var="cell" items="${row}" varStatus="rowStatus">
<td class="data_extract">
<c:choose>
<c:when test="${results.types[rowStatus.index].array}">
<c:set var="comma" value="," />
<c:forEach var="elem" items="${cell}" varStatus="cellStatus">
<c:set var="myVar" value="${cellStatus.first ? '' : myVar} ${elem} ${cellStatus.last ? '' : comma}" />
</c:forEach>
<span class="mouseover_text" title="${myVar}">${myVar}</span>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${results.types[rowStatus.index].componentType.class.name eq 'java.sql.Timestamp'}">
<fmt:formatDate value="${cell}" pattern="${date_pattern}" />
</c:when>
<c:otherwise>
${cell}
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
</td>
</c:forEach>
</tr>
</c:forEach>
</table>
答案 0 :(得分:3)
JSTL将调用标准的setter getter,这样你就可以使用getClass()和getName()方法
<c:if test="${results.types[rowStatus.index].componentType.class.name
eq 'java.util.Date' }">