'framework/struts2'에 해당되는 글 1건

  1. 2011.01.28 [struts2] - s:iterator, s:if 사용하자
iterator는 value 에서 list 객체를 사용하고 객체의 id를 'field'라 정함.
id를 토대로 해당 리스트의 값에 접근한다.

if 이넘은 test, id 라는 넘을 사용한다는데.. 여기서 사용한 test는 boolean을 체크할때 사용한다.

<s:iterator value="initVo.fields" id="field">
    <s:if test="#field == 'authKey'">
        <s:textfield name='%{initVo.actionName}.%{field}' value='입력하고 싶은 값'> <li><s:property/>    </li></s:textfield><br>
    </s:if>
    <s:else>
        <s:textfield name='%{initVo.actionName}.%{field}' value=''> <li><s:property/></li></s:textfield><br>
    </s:else>
</s:iterator>

#field == 'authKey' <- 리스트의 값이 'authKey'랑 같으면 해당 textfield를 출력하는 코드.
물론 or(||) and(&&) 조건도 사용할 수 있다.
Posted by 짱가쟁이
이전버튼 1 이전버튼