2015-01-25 3 views
1

Jstl 속성 $ {theDetail.id}을 JSTL의 foreach에서 Java 함수 안에서 어떻게 사용할 수 있습니까? 나는 많은 노력을했지만 아무런 효과가 없습니다.Java 메소드로 JSTL var을 조합하십시오.

<c:forEach items="<%= facade.getAllDetails() %>" var="theDetail"> 

    // how to use ${theDetail.id} inside this java function 
    <c:forEach items="<%= facade.getSomeStuffById(...) %>" vars="theStuff"> 
     ${theStuf.name} 
    </c:forEach> 
</c:forEach> 

답변

2

JSP 태그 안에 스크립틀릿 표현식을 사용하지 마십시오. 사실, 스크립틀릿을 전혀 사용하지 마십시오. JSP 태그는 JSP EL 표현식을 사용하도록 설계되었습니다. 스크립틀릿 표현식이 아닙니다.

코드를 작성하는 방법은 facade 내가 찾고 있어요 어디

<c:forEach items="${facade.allDetails}" var="theDetail"> 

    <c:forEach items="${facade.getSomeStuffById('someHardCodedId')}" var="theStuff"> 
     ${theStuff.name} 
    </c:forEach> 
</c:forEach> 
+0

예, 그게 전부 어떤 범위의 속성 가정이다. 하지만 {theDetail.id}의 ID로 어떻게 사용할 수 있습니까? getSomeStuffById() 안에 $ {theDetail.id}를 추가하려고하면 500 오류가 발생합니다. – CodeWhisperer

+0

'$ {facade.getSomeStuffById (theDetail.id)}' –

+0

고마워요! 정말 멋져! – CodeWhisperer