如何从主jsp页面获取tile jsp页面的Map值

时间:2017-06-15 05:15:38

标签: java jsp collections jsp-tags tiles

实际上我正试图从一个mainpage.jsp页面获取一个地图值到tile页面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>

页面中显示错误:

  

无法插入页面&#39; $ {lhsSrcMap}&#39; :null [ServletException in:/jsp/common/lhsListing.jsp]评估自定义操作属性&#34; items&#34;时发生错误值&#34; $ {lhsSrcMap.value [&#39; LIST&#39;] [&#39; SRC_DTL_MAPS_LIST&#39;] [&#39; FIELD_LIST&#39;]}&#34;:无法找到&#34;值&#34;的值在class&#34; java.lang.String&#34;的对象中使用operator&#34;。&#34; (空)&#39;

1 个答案:

答案 0 :(得分:1)

  

我的问题得到了解决方案   我们可以使用Implicit ObjectsUnified Expression Language

     

我在JSTL中使用了 <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>

mainpage.jsp

<c:forEach var="fieldRec" varStatus="status" items="${tileLhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" > 

//something  

</c:forEach>

lhsListing.jsp

<c:forEach var="fieldRec" varStatus="status" items="${requestScope.tileLhsSrcMap.value['LIST']['SRC_DTL_MAPS_LIST']['FIELD_LIST']}" > 

//something  

</c:forEach>

或使用 requestScope

lhsListing.jsp

SELECT 
 CASE
      WHEN notes.column1 IS NOT NULL
      THEN ''
        ||  notes.column1 
        || ' '
      WHEN notes.Column2 IS NOT NULL
      THEN ''
         || TO_CHAR(notes.Column2)
        || ' '
    END TEST
  FROM notes