【发布时间】:2013-12-26 04:05:10
【问题描述】:
我尝试在这里查看不同的问题,但没有一个完全匹配。
I get Map data from the source as <Key,Value> pairs, typically a JSON source
我尝试过类似的方法
<tr>
<c:forEach items="${record.attributes.entry}" var="entry">
<td style="width: 20%; height: 15px;">
<img
src="${entry['p_csl_thumbnail_url']}"
class="img-responsive" />
</td>
<td style="width: 65%; height: 15px;" class="ellipses">
${entry['p_csl_description']}
</td>
<td style="width: 15%; height: 15px;" class="ellipses">
${entry['p_csl_close_time_est']}
</td>
</c:forEach>
</tr>
entry 是一个 Map,我正在尝试使用键获取值。
样本数据:
{
"records": [
{
"aggregationCount": "0",
"attributes": {
"entry": [
{
"key": "P_CSL_Description",
"value": " [i]test[/i] Description"
},
{
"key": "P_RSCG_Lot_Creation_Time",
"value": "0"
},
{
"key": "P_CSL_Close_Time_EST",
"value": "2013-09-16 06:25:00 PM EST"
},
{
"key": "P_CSL_Thumbnail_Url",
"value": "http://localhost:9889/54205775_lists.jpg"
}
]
},
"recordId": "LCOM6693760",
"selfLocation": {
"uri": "http://localhost:8899/search-engine/v1/collections/csl/search?recordId=LCOM6693760"
}
}
]
}
更新
<tr>
<td style="width: 10%; height: 15px;">
<img src="${record.attributes.entry['P_CSL_Thumbnail_Url']}" class="img-responsive" />
</td>
<td style="width: 80%; height: 15px;">
${record.attributes.entry['P_CSL_Description']}
</td>
<td style="width: 10%; height: 15px;">
${record.attributes.entry['P_CSL_Close_Time_EST']}
</td>
</tr>
我遇到了错误
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NumberFormatException: For input string:
"P_CSL_Thumbnail_Url" at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492) at
java.lang.Integer.parseInt(Integer.java:527) at
javax.el.ListELResolver.coerce(ListELResolver.java:173) at
javax.el.ListELResolver.getValue(ListELResolver.java:52) at
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183) at
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026)
at
org.apache.jsp.view.jsp.search_jsp._jspx_meth_c_005fforEach_005f4(search_jsp.java:1225)
【问题讨论】:
-
所以你得到了价值。有什么问题?
-
record.attributes.entry涉及的对象有哪些? -
record.attributes.entryia aJSONArray你也可以在这个数组上解析