如何从主 jsp 页面获取 tiles jsp 页面的地图值
How to get a Map value to the tiles jsp page from main jsp page
实际上,我正在尝试将地图值从 mainpage.jsp 页面获取到图块页面 lhsListing.jsp。有没有办法传递地图对象。下面是我的代码请帮我找人。
mainPage.jsp
<c:forEach var="lhsSrcMap" varStatus="status" items="${lhsListMap}">
<tiles:insert page="/jsp/common/lhsListing.jsp" >
<tiles:put name="lhsSrcMap" value="${lhsSrcMap}"/>
</tiles:insert>
lhsListing.jsp
<c:set var="lhsSrcMap"><tiles:get name="lhsSrcMap"/></c:set>
<c:forEach var="fieldRec" varStatus="status"items="${lhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" >
//something
</c:forEach>
页面显示错误:
Can't insert page '${lhsSrcMap}' : null [ServletException in:/jsp/common/lhsListing.jsp] An error occurred while evaluating custom action attribute "items" with value "${lhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}": Unable to find a value for "value" in object of class "java.lang.String" using operator "." (null)'
I got a solution for my question.
we can use Implicit Objects of the Unified Expression Language.
I used scope="request"
in JSTL.
mainpage.jsp
<c:forEach var="lhsSrcMap" varStatus="status" items="${lhsListMap}">
<c:set var="tileLhsSrcMap" value="lhsSrcMap" scope="request"/>
<tiles:insert page="/jsp/common/lhsListing.jsp" >
</tiles:insert>
</c:forEach>
lhsListing.jsp
<c:forEach var="fieldRec" varStatus="status" items="${tileLhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" >
//something
</c:forEach>
或使用requestScope
lhsListing.jsp
<c:forEach var="fieldRec" varStatus="status" items="${requestScope.tileLhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" >
//something
</c:forEach>
实际上,我正在尝试将地图值从 mainpage.jsp 页面获取到图块页面 lhsListing.jsp。有没有办法传递地图对象。下面是我的代码请帮我找人。
mainPage.jsp
<c:forEach var="lhsSrcMap" varStatus="status" items="${lhsListMap}">
<tiles:insert page="/jsp/common/lhsListing.jsp" >
<tiles:put name="lhsSrcMap" value="${lhsSrcMap}"/>
</tiles:insert>
lhsListing.jsp
<c:set var="lhsSrcMap"><tiles:get name="lhsSrcMap"/></c:set>
<c:forEach var="fieldRec" varStatus="status"items="${lhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" >
//something
</c:forEach>
页面显示错误:
Can't insert page '${lhsSrcMap}' : null [ServletException in:/jsp/common/lhsListing.jsp] An error occurred while evaluating custom action attribute "items" with value "${lhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}": Unable to find a value for "value" in object of class "java.lang.String" using operator "." (null)'
I got a solution for my question.
we can use Implicit Objects of the Unified Expression Language.I used
scope="request"
in JSTL.
mainpage.jsp
<c:forEach var="lhsSrcMap" varStatus="status" items="${lhsListMap}">
<c:set var="tileLhsSrcMap" value="lhsSrcMap" scope="request"/>
<tiles:insert page="/jsp/common/lhsListing.jsp" >
</tiles:insert>
</c:forEach>
lhsListing.jsp
<c:forEach var="fieldRec" varStatus="status" items="${tileLhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" >
//something
</c:forEach>
或使用requestScope
lhsListing.jsp
<c:forEach var="fieldRec" varStatus="status" items="${requestScope.tileLhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" >
//something
</c:forEach>