【发布时间】:2024-04-22 00:00:02
【问题描述】:
在使用表达式语言的 .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> 返回标题名称。
【问题讨论】:
-
这不是那个的复制品。