2014-06-13 22 views
1

我在這裏使用requestScope項目一次。這裏首先foreach循環正常工作。我可以在jsp中多次使用相同的requestScope

  <div class="list-group"> 
           <a href="#" class="list-group-item active">Manufacturer List</a> 
           <c:forEach items="${requestScope.items}" var="item"> 
            <a href="#" class="list-group-item">${item.itemDesc} ( ${item.model} ) </a> 
           </c:forEach> 
          </div> 

我想再次使用相同的requestScope項目。

      <c:forEach items="${requestScope.topitems}}" var="topitem"> 
           <div class="col-6 col-sm-6 col-lg-4"> 
            <h2>${topitem.itemDesc}</h2> 
            <p> 
             Manufacturer : ${topitem.manufacturer} 
             Model : ${topitem.model} 
             Part No : ${topitem.partNo} 

             <p><a class="btn btn-default" href="#" role="button">View details »</a></p> 
            </p> 
           </div> 
          </c:forEach> 

使用第二個foreach循環後,我得到以下錯誤。

例外

org.apache.jasper.JasperException:javax.el.PropertyNotFoundException: 類 'java.lang.String中' 不具有財產 'itemDesc'。 根本原因

javax.el.PropertyNotFoundException:類'java.lang.String'確實沒有 沒有屬性'itemDesc'。

+3

似乎是一個多餘的「}」在你的2nd for循環中:items =「$ {requestScope.topitems}}」。我最近學到的另一件事是,如果在變量聲明之後添加一個空格,則會發生同樣的錯誤:http://stackoverflow.com/questions/24073693/jsp-error-for-not-correctly-use-jstl/ 24073828#24073828 –

+0

@MichaelSanchez如果你把這個作爲回答線程可能已被標記爲回答:) – Teddy

回答

相關問題