Toggle theme
문제를 잘 정의하는 것은 문제를 절반 해결한 것이다. - 2023.12
사용자 도구
Toggle theme
로그인
사이트 도구
검색
도구
문서 보기
이전 판
PDF로 내보내기
Fold/unfold all
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
현재 위치:
start
»
wiki
»
spring
»
jstl
wiki:spring:jstl
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== JSTL 활용법 ====== <WRAP left notice 80%> * description : JSTL 관련된 사용방법 * author : 주레피 * email : dhan@repia.com * lastupdate : 2020-03-19 </WRAP> <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 ===== [[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 ===== LIST 순회 <code jsp> <c:forEach var="entry" items="${resultMap }" varStatus="status"> <tr> <td>${entry.key }</td> <td>${entry.value }</td> <td>${entry.key.class }</td> </tr> </c:forEach> </code> 키값으로 값 불러오기 1 <code jsp> <c:out value='${resultMap["${key}"]' } /> </code> 키값으로 값 불러오기 2 <code jsp> <c:set var='idAsString'>${resultInfo.id }</c:set> <c:out value='${resultMap[idAsString].id }' /> </code> [[https://enterkey.tistory.com/391|JSTL 에서 MAP 접근, 출력(KEY로 바로 값 추출)]] ===== Test ===== [[https://dondons.tistory.com/16|[JSTL] 비교연산 eq, ne, empty]] eq <code jsp> null: <c:if test='${ null eq name }'></c:if> 숫자: <c:if test='${ 0 eq name }'></c:if> 문자: <c:if test='${ 'string' eq name }'></c:if> </code> ne or != <code jsp> null: <c:if test='${ null ne name }'></c:if> 숫자: <c:if test='${ 0 eq name }"></c:if> 문자: <c:if test='${ "string" eq name }'></c:if> </code> empty <code jsp> 객체의 값이 비어있을 때: <c:if test='${empty map }'</c:if> 객체의 값이 있을 때: <c:if test='${!empty map }'></c:if> </code> ===== Tag ===== [[https://kkith.blog.me/220352327172|전자정부 표준프레임워크 사용자 태그 정의 하기]] \\ [[https://www.4te.co.kr/569|클래식 커스텀 태그]] \\ ===== Tip ===== ===== Troubleshooting ===== ===== Ref ===== * [[https://littlecarbb.tistory.com/entry/34-JSTL-core-%EB%B3%80%EC%88%98-%EC%84%A4%EC%A0%95-%ED%83%9C%EA%B7%B8-cset-cremove|[34] JSTL core : 변수 설정 태그 <c:set> <c:remove>]] * [[https://meaownworld.tistory.com/123|JSTL c tag 에서 eq, ne null check 하기]] {{tag>주레피 JSTL jstl}}
/volume1/web/dokuwiki/data/pages/wiki/spring/jstl.txt
· 마지막으로 수정됨: 2023/01/13 18:44 (바깥 편집)
문서 도구
문서 보기
이전 판
역링크
PDF로 내보내기
Fold/unfold all
맨 위로