영보의 SystemOut.log

[JSP] JSP에서 JSTL사용하여 타임 셋팅해서 팝업띄우기 본문

Web/JSP

[JSP] JSP에서 JSTL사용하여 타임 셋팅해서 팝업띄우기

영보로그 2021. 2. 10. 16:28
반응형

 JSTL 타임 셋팅

 

 

1. 라이브러리 다운 받기

 

 

mvnrepository.com/artifact/javax.servlet/jstl/1.2

 

Maven Repository: javax.servlet » jstl » 1.2

Professional Java Data: RDBMS, JDBC, SQLJ, OODBMS, JNDI, LDAP, Servlets, JSP, WAP, XML, EJBs, CMP2.0, JDO, Transactions, Performance, Scalability, Object and Data Modeling (2001)by Carl Calvert Bettis, Michael Bogovich, Sean Rhody, Mark Wilcox, Kelly Lin P

mvnrepository.com

먼저 위의 사이트에서 JSTL jar파일을 다운받아 주세요.

 

 

 

2. taglib 지시자 선언

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

 - java에서 jstl 사용하려면 위 코드 꼭 작성하셔야 합니다!

 

 

 

3. 코드

<%--test--%>
                <jsp:useBean id="NowDate" class="java.util.Date"/>
                <fmt:formatDate value="${NowDate}" pattern="yyyyMMddhhmm" var="nowDate"/>
                ${nowDate}
                <!-- <a href="https://qh5944.tistory.com/" target="_blank" style="color:#fff; display:block; padding:25px 0 25px 45px;background:url(/admission/images/201214.png)10px center no-repeat;color:#28141f;font-size:18px;background-size:24px; font-weight:900">내용확인<br>(내용)</a> -->

                <!-- 지금 현재 창 -->
                <c:if test="${nowDate<202102080900}">
                    <c:set var="context_1"
                           value='내용'/>
                </c:if>


                <!-- 조건 -->
                <c:if test="${nowDate>202102080900 && nowDate<202102101800}">
                    <c:set var="context_1"
                           value='내용1'/>
                </c:if>

                <c:if test="${nowDate>202102101800 && nowDate<202102141200}">
                    <c:set var="context_1"
                           value='내용2'/>
                </c:if>

                <c:if test="${nowDate>202102141200 && nowDate<202102151200}">
                    <c:set var="context_1"
                           value='내용3'/>
                </c:if>

                <c:if test="${nowDate>202102151200 && nowDate<202102151300}">
                    <c:set var="context_1"
                           value='내용4'/>
                </c:if>

                <c:if test="${nowDate>202102151300 && nowDate<202102152100}">
                    <c:set var="context_1"
                           value='내용5'/>
                </c:if>

                <c:if test="${nowDate>202102152100 && nowDate<202102161300}">
                    <c:set var="context_1"
                           value='내용6'/>
                </c:if>

                <c:if test="${nowDate>202102161300 && nowDate<202102162000}">
                    <c:set var="context_1"
                           value='내용7'/>
                </c:if>

                <c:if test="${nowDate>202102162000 && nowDate<202102162100}">
                    <c:set var="context_1"
                           value='내용8'/>
                </c:if>

                <c:if test="${nowDate>202102162100 && nowDate<202102172000}">
                    <c:set var="context_1"
                           value='내용9'/>
                </c:if>

                <c:if test="${nowDate>202102172000 && nowDate<202102182100}">
                    <c:set var="context_1"
                           value='내용10'/>
                </c:if>

                <c:if test="${nowDate>202102182100}">
                    <c:set var="context_1"
                           value='내용11'/>
                </c:if>

            </div>
            
            <div class="popup" style="background:#0a988c; font-size:19px;" data-expired="2021-02-03 11:20">
                    <a href="javascript:void(alert('<c:out value="${context_1}"/>')); " title="새창에서 열림">                       
                        내용<br>
                        (내용!!)</a>
                </div>
          

 

 

반응형