Java 使用JSTL从映射中获取值
我试着在这里看不同的问题,但没有一个完全匹配Java 使用JSTL从映射中获取值,java,json,jsp,map,jstl,Java,Json,Jsp,Map,Jstl,我试着在这里看不同的问题,但没有一个完全匹配 我成对地从源代码获取地图数据,通常是JSON源代码 我试过这样的东西 <tr> <c:forEach items="${record.attributes.entry}" var="entry"> <td style="width: 20%; height: 15px;"> <img src="${entry['p_csl_thu
我成对地从源代码获取地图数据,通常是JSON源代码
我试过这样的东西
<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>
更新
<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>
像这样的声明
<c:forEach items="${record.attributes.entry}" var="entry">
获取键和
${entry.value}
获取值。那么您正在获取值。问题是什么?在record.attributes.entry
中涉及的对象是什么?record.attributes.entry
iaJSONArray
您也可以在这个数组上解析。我想我已经完成了。我所做的只是在comaprison中犯了一个简单而愚蠢的错误,这导致了这个问题@Reddy,我不知道基础地图是什么类型,但是如果是<代码> HashMap <代码>,就不可能保存它们在JSON中出现的顺序。@ ReDy考虑使用不同的JSON解析器来生成实际的DTOS并按照您的意愿访问它的字段。因为我不能控制源JSON,我该如何从我的终端开始处理它。在我的控制器中,我获取JSON对象并将其传递给jsp@Reddy如果您不控制JSON解析,那么您必须使用,例如,record.attributes.entry['P\u CSL\u thumboil\u Url']
来获取该键的值(其他键也是如此)。您不会使用
。
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)
<c:forEach items="${record.attributes.entry}" var="entry">
<td style="width: 20%; height: 15px;">
<img
src="${entry.key}"
class="img-responsive" />
</td>