앱)jstl sample 예제

Posted by HULIA(휴리아)
2018. 6. 12. 15:31 백엔드개발/자바스프링
===URL관련
location.href="<c:url value='/xxx/aaaa.do' />";
url : "<c:url value='/xxx/aaaa.do' />",
<span><a href="<c:url value='/aaaa/ggg.do' />" targe='_blank'>dkfkdkj</a>
document.searchForm.action ="<c:url value='/xxx/aaaa.do' />"

<c:url value="/ttet/tete.do">
   <c:param name="keyword" value="${searchTerm}" />
   <c:param name="keyword2" value="${searchTerm2}" />
</c:url>

===조건문관련
<c:if test="${null != xxxx && !empty xxxx}">
       <c:forEach var="xxxx" items="${xxxx}">
            ${xxxx.kkkk}
       </c:forEach>
</c:if>
<option value="kkk" <c:if test="${type} eq 'kkkok'}">selected</c:if>>History</option>


===조건문관련2
<c:choose>
    <c:when test="${null != pppp && !empty pppp}">
     </c:when>
     <c:when test="${null != pppp && !empty pppp}">
     </c:when>
     <c:when test="${null != pppp && !empty pppp}">
     </c:when>
     <c:otherwise>
     </c:otherwise>
</c:choose>

===반복문
<c:forEach var="xxxx" items="${xxxx}" varStatus="lineIndex">
     <!--반복할 내용 -->
</c:forEach>

lineIndex.current:현재 순환중인 아이템을 가져옵니다
lineIndex.index:현재 순환중인 아이템의 인덱스(0베이스)를 가져옵니다
lineIndex.count:현재 순환중인 아이템의 인덱스(1베이스)를 가져옵니다
lineIndex.first:현재 순환중인 아이템이 첫번째 아이템인지 여부를 확인합니다(booelan)
lineIndex.last:현재 순환중인 아이템이 마지막 아이템인지 여부를 확인합니다(boolean)
lineIndex.begin:forEach에서 지정할 수 있는 begin값을 가져옵니다
lineIndex.end:forEach에서 지정할 수 있는 end값을 가져옵니다
lineIndex.step:forEach에서 지정할 수 있는 step값을 가져옵니다

===세팅관련
<c:set var="sum" value="0" /><!-- sum변수에 0을 세팅 -->
<c:set var="sum" value="${sum+statisticsList.totalCount}" /><!--sum에 totalCount값을 더한후 sum변수에 세팅 -->


===출력관련
<c:out value="${now}" />
<c:out value="${fn:replace(list.userID, '||', '-')}" />


===문자열관련
<c:if test="${fn:contains(name, "searchString")}">
<c:if test="${fn:endWith(filename, ".txt")}">
<c:if test="${fn:indexOf(name, "-")}">
<c:if test="${fn:length(name)}">
<c:if test="${fn:startWith(filename, ".txt")}">
<c:if test="${fn:subString(filename, 6, 0)}">
<c:if test="${fn:subStringAfter(filename, "-")}">
<c:if test="${fn:subStringBefore(filename, "-")}">


===import관련
<c:import url="ftp://ftp.example.com/pacakge/index.html" />

<c:import url="/tkkdj/ted.do">
   <c:param name="keyword" value="${searchTerm}" />
</c:import>


===리다이렉트
<c:redirect>
URL이 변경되면서 페이지 이동