2015-01-12 33 views
1

我使用JSTL標記比較了來自不同列表中每個列表中的兩個不同值,但我一直在收到錯誤。我試圖改變與它相關的括號,但沒有工作。我搜索比較JSTL中的兩個列表值,但沒有人幫助我。比較JSTL標記中的兩個列表值

<c:forEach items="${commentsList}" var="commentsList"> 
    <c:choose> 
     <c:when test="${ ${commentsList.user.id} == '${blog.user.id}' }"> 
      <li> 
       <div class="timeline-panel" style="float:right"> 
        <div class="timeline-heading" align="left"> 
         <b>${commentsList.user.firstName}&nbsp;${commentsList.user.lastName}</b> 
        </div><hr> 
        <div class="timeline-body" style="float: right;"> 
         <p>${commentsList.comment}</p> 
        </div> 
       </div> 
      </li> 
     </c:when>        
     <c:otherwise> 
      <li class="timeline-inverted"> 
       <div class="timeline-panel">           
        <b>${commentsList.user.firstName}&nbsp;${commentsList.user.lastName}</b><hr> 
        <div class="timeline-body"> 
         <p>${commentsList.comment}</p>             
        </div> 
       </div> 
      </li> 
     </c:otherwise>        
    </c:choose> 
</c:forEach> 

錯誤是

"${ ${commentsList.user.id} == '${blog.user.id}' }" contains invalid expression(s): javax.el.ELException: Error Parsing: ${ ${commentsList.user.id} == '${blog.user.id}' } 

我以前沒兩個列表值進行比較,順便說一句,我可以在JSTL權比較兩個列表值?

回答

2

還有一個額外的$。 試試這個:

<c:when test="${ commentsList.user.id eq blog.user.id}"> 
+1

感謝那些工作。看來$ infront將消除內部{}的需求。 –

1

你應該改變以

<c:when test="${commentsList.user.id eq blog.user.id}"> 
+1

已更正配偶。謝謝.. –