【发布时间】:2013-12-11 08:44:09
【问题描述】:
我从 JSON 响应中获取一个属性/参数作为 EPOCH 时间变量。
我想转换成dd/MM/yyyy hh:mm:ss格式并显示在表格中
<tbody>
<c:if
test="${not empty jsonResult && not empty jsonResult.records}">
<c:forEach items="${jsonResult.records}" var="record">
<tr>
<td style="width:15%;"><img src="${record.attributes.P_Image_Path}" class="img-responsive" /></td>
<td style="width:15%;">${record.attributes.P_Description}</td>
<td style="width:55%;">${record.attributes.P_Username_Seller}</td>
<%
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
System.out.println(sdf.format( new java.util.Date(${record.attributes.P_Close_Time}));
%>
<td style="width:15%;">${record.attributes.P_Close_Time}</td>
</tr>
</c:forEach>
</c:if>
</tbody>
但是它无法编译 JSP。我找不到如何使用 JSON 中的 scriplet 和模型属性值的组合
更新 试过这个 - 不工作
<c:set var="now" value="<%=new java.util.Date(${record.attributes.P_Close_Time}%>" />
<td style="width: 15%;"><fmt:formatDate pattern="dd/MM/yyyy hh:mm:ss" value="${now}" /></td>
试过了 - 不工作
<td style="width: 15%;"><fmt:formatDate pattern="dd/MM/yyyy hh:mm:ss" value="<%=new java.util.Date(${record.attributes.P_Close_Time})%>" /></td>
试过了 - 不工作
<td style="width: 15%;"><fmt:formatDate pattern="dd/MM/yyyy hh:mm:ss" value="<%=new java.util.Date(record.attributes.P_Close_Time)>" /></td>
【问题讨论】:
-
你不能在
${...}里面使用<% ... %> -
@MicheleMariotti,可能是:) 请解决!
标签: java json jsp date scriptlet