表达式语言 - 标头值为null

时间:2017-08-08 11:16:57

标签: jsp foreach el

在.jsp页面中使用表达式语言,我想要检索所有标题名称及其值。

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
    <tr>
        <th>Name</th>
        <th>Value</th>
    </tr>
    <c:forEach items="${pageContext.request.headerNames}" var="item">
    <tr>
        <td>${item}</td>
        <td>${header["${item}"]}</td>
    </tr>
    </c:forEach>
</table>
据我所知,

标题是

  • 引用标记是指定JavaBean中的属性或地图中的

但是<td>${header["${item}"]}</td>返回null,即使<td>${item}</td>返回标题名称。

1 个答案:

答案 0 :(得分:2)

java.util.ArrayList

应该是

<td>${header["${item}"]}</td>

或者,您可以在jstl

中使用隐式头对象
<td>${header[item]}</td>
相关问题