본문 바로가기

WebStudy

JSTL forEach, FroToken 속성

varStatus =" status"

 

status.current   현재의 for문에 해당하는 번호

status.index 0부터의 순서

status.count 1부터의 순서

status.first  현재 루프가 처음인지 확인

status.last  현재 루프가 마지막인지 확인

status.begin for문의 시작 값

status.end   for문의 끝 값

status.step  for문의 증가값

 

----------------------- email jstl을 이용하여 선택

 

<c:forTokens var="str" items="${info.email}" delims="@"
        varStatus="status">
        <c:choose>
         <c:when test="${status.index ==0 }">
          <c:set var="email" value="${str }" />
         </c:when>
         <c:when test="${status.index ==1 }">
          <c:set var="domain" value="${str }" />
         </c:when>
        </c:choose>
       </c:forTokens><input type="text" name="email" class="email" value="${email }" />@
       <input type="text" name="domain" class="domain" value="${domain }">
       <c:set var="list" value="직접입력,naver.com,gmail.com,daum.net" scope="application" />
       <select name="selectDomain" class="selectDomain">
        <c:forEach items="${fn:split(list, ',')}" var="one">
         <option value="${one}" ${one == domain ? 'selected' : ''}>${one}</option>
        </c:forEach>
      </select>

 

------------------------------------다수의 값을 다수의 값과 비교하여 cehckbox

<!-- info.value 에는 reading/climbing/fishing 의 값이 들어있다.  -->

<c:set var="list" value="reading,climbing,fishing,watching,basketball,soccer" scope="application"/>
      <c:forEach items="${fn:split(list,',') }" var="one">
       
       <input type="checkbox" name="hobby" value="${one }" ${fn:indexOf(info.hobby,one) >= 0 ? 'checked':''}/>${one }
       
      </c:forEach>

 

 

------------------------------비교할 값을 손수 입력

 

<input type="radio" name="path" value="media" ${info.path=='media'?'checked':'' } />TV/신문/잡지
       <input type="radio" name="path" value="internet" ${info.path=='internet'?'checked':'' }/>인터넷
       <input type="radio" name="path" value="friend" ${info.path=='friend'?'checked':'' }/>동료
       <input type="radio"  name="path" value="ect" ${info.path=='ect'?'checked':'' }/>기타

'WebStudy' 카테고리의 다른 글

캐시 막는 법.  (0) 2015.06.30
cookie  (0) 2015.06.23
jstl tag  (0) 2015.06.23
DB싱글톤 방식, ConnectionPool  (0) 2015.06.23
session 에 관한 ...  (0) 2015.06.22