セッションに保存されているハッシュマップがあります。hashMap はマップのマップです。
HashMapStoredInSession ={"290" = {text="abc", response="someText"}, "276"={text="xyz", response="random"}};
スクリプトレットを使用したくありません。しかし、私は 1 つのスクリプトレットで立ち往生しており、それを機能させることができないようです。私が間違っている提案は素晴らしいでしょう。次の SCRIPTLET + JSTL の組み合わせが機能します
スクリプトレット:
<%
Map hMap= (Map)request.getSession().getAttribute("HashMapStoredInSession");
pageContext.setAttribute("mapofMaps", hMap);
%>
JSTL コード:
<c:if test="${param.ID != 'null' && not empty param.ID}">
<c:set var="someID" value="${param.ID}" scope="session"/>
</c:if>
<c:forEach items="${mapofMaps}" var="outerMap">
<c:if test="${outerMap.key == someID}"> // this is the line where exception is thrown when the above scriptlet code is replaced with JSTL below
<c:forEach items="${outerMap.value}" var="innerMap">
<c:if test="${innerMap.key == 'param1'}">
<c:set var="response1" value="${innerMap.value}"/>
</c:if>
<c:if test="${innerMap.key == 'param2'}">
<c:set var="response2" value="${innerMap.value}"/>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
ここで、スクリプトレット コードを次のコードに置き換えようとすると (JSTL コードを変更せずに)
<c:set var="mapofMaps" value ='<c:out value ="<%=request.getSession().getAttribute("HashMapStoredInSession")%>"/>'/>
次のエラーが表示されます
An error occurred while evaluating custom action attribute "test" with value "${outerMap.key == someID}":
Unable to find a value for "key" in object of class "java.lang.String" using operator "." (null)