사용자 도구

사이트 도구


wiki:spring:jstl

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
wiki:spring:jstl [2020/03/24 21:35]
dhan
wiki:spring:jstl [2023/01/13 18:44] (현재)
줄 7: 줄 7:
 </WRAP> </WRAP>
 <WRAP clear/> <WRAP clear/>
 +
 +===== Rule =====
 +<code jsp>
 +<c:if test='${"string" eq name }'></c:if>
 +
 +<td>${entry.key.class }</td>
 +</code>
 +> single 가급적 quotation으로 시작하고 그 내부에서 string일 경우 double quotation으로 처리한다.
 +> 마지막은 ${변수 }, 즉 space로 종료한다.
 +
 +===== c:out =====
 +[[https://webcoding.tistory.com/entry/JSP-JSTL-cout-%ED%83%9C%EA%B7%B8-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0|[JSP] JSTL c:out 태그 사용하기]]
  
 ===== Choose ===== ===== Choose =====
 [[https://enzycut.tistory.com/entry/JSTLchoose-when-otherwise-%EC%82%AC%EC%9A%A9%EB%B2%95|[JSTL]choose와 when, otherwise 사용법]] [[https://enzycut.tistory.com/entry/JSTLchoose-when-otherwise-%EC%82%AC%EC%9A%A9%EB%B2%95|[JSTL]choose와 when, otherwise 사용법]]
 +
 +===== Format =====
 +[[https://zzznara2.tistory.com/688|[jstl] Date형과 String형인 경우 jstl(fmt)로 날짜 포맷에 맞게 출력하는 방법]] \\
 +[[https://cofs.tistory.com/39|jstl / el / 나누기 / % / 소수점 표시하기]] \\
 +
 +===== Length =====
 +List Size값 출력
 +<code jsp>
 +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
 +${resultList.size } X
 +${fn:length(resultList) } O
 +</code>
 +
 +===== List =====
 +[[https://stackoverflow.com/questions/14737337/how-to-iterate-over-a-list-of-lists-in-jstl|How to iterate over a list of lists in jstl?]] \\
 +<code jsp>
 +<c:forEach var="innerList" items="${mylist}">
 +    <c:forEach var="obj" items="${innerList}">
 +        <c:out value="${obj.val}"></c:out>
 +    </c:forEach>
 +</c:forEach>
 +</code>
 +
  
 ===== Map ===== ===== Map =====
 LIST 순회 LIST 순회
 <code jsp> <code jsp>
-<c:forEach var="entry" items="${resultMap}" varStatus="status">+<c:forEach var="entry" items="${resultMap }" varStatus="status">
     <tr>     <tr>
-        <td>${entry.key}</td> +        <td>${entry.key }</td> 
-        <td>${entry.value}</td> +        <td>${entry.value }</td> 
-        <td>${entry.key.class}</td>+        <td>${entry.key.class }</td>
     </tr>     </tr>
 </c:forEach> </c:forEach>
줄 25: 줄 60:
 키값으로 값 불러오기 1 키값으로 값 불러오기 1
 <code jsp> <code jsp>
-<c:out value="${resultMap['${key}']} />+<c:out value='${resultMap["${key}"]} />
 </code> </code>
  
 키값으로 값 불러오기 2 키값으로 값 불러오기 2
 <code jsp> <code jsp>
-<c:set var="idAsString">${resultInfo.id }</c:set> +<c:set var='idAsString'>${resultInfo.id }</c:set> 
-<c:out value="${resultMap[idAsString].id }/>+<c:out value='${resultMap[idAsString].id }/>
 </code> </code>
  
줄 40: 줄 75:
 eq eq
 <code jsp> <code jsp>
-null: <c:if test="${ null eq name }"></c:if> +null: <c:if test='${ null eq name }'></c:if> 
-숫자: <c:if test="${ 0 eq name }"></c:if> +숫자: <c:if test='${ 0 eq name }'></c:if> 
-문자: <c:if test="${ 'string' eq name }"></c:if>+문자: <c:if test='${ 'string' eq name }'></c:if>
 </code> </code>
  
 ne or != ne or !=
 <code jsp> <code jsp>
-null: <c:if test="${ null ne name }"></c:if> +null: <c:if test='${ null ne name }'></c:if> 
-숫자: <c:if test="${ 0 eq name }"></c:if> +숫자: <c:if test='${ 0 eq name }"></c:if> 
-문자: <c:if test="${ 'stringeq name }"></c:if>+문자: <c:if test='${ "stringeq name }'></c:if>
 </code> </code>
  
 empty empty
 <code jsp> <code jsp>
-객체의 값이 비어있을 때: <c:if test="${empty map}"</c:if> +객체의 값이 비어있을 때: <c:if test='${empty map }'</c:if> 
-객체의 값이 있을 때: <c:if test="${!empty map}"></c:if>+객체의 값이 있을 때: <c:if test='${!empty map }'></c:if>
 </code> </code>
 +
 +===== Tag =====
 +[[https://kkith.blog.me/220352327172|전자정부 표준프레임워크 사용자 태그 정의 하기]] \\
 +[[https://www.4te.co.kr/569|클래식 커스텀 태그]] \\
 +
  
 ===== Tip ===== ===== Tip =====
  
-===== Trouble shooting =====+===== Troubleshooting =====
  
 ===== Ref ===== ===== Ref =====
/volume1/web/dokuwiki/data/attic/wiki/spring/jstl.1585053353.txt.gz · 마지막으로 수정됨: 2022/03/10 19:52 (바깥 편집)