JSTL변수 ${} 를 JSP에서 사용 하기, 변수 혼용하기

JSTL ---> JSP
///////////////////

<c:set var="변수이름" value="${JSTL변수}"/>

<%
String strJsp=(String)pageContext.getAttribute("변수이름");
%>


////////////////

JSP ---> JSTL

<%
String strJSP="A123"
pageContext.setAttribute("strJSTL",strJSP);
%>

<c:out value="${strJSTL}" />

=-========================================

<%
int jspVal = 888;
pageContext.setAttribute("jspVal", jspVal) ;
%>
<c:out value="${jspVal}" default="999"></c:out>
<c:set var="tmpValue" value="${jspVal}"></c:set>
<c:out value="${tmpValue}" default="0"></c:out>
<%= pageContext.getAttribute("tmpValue") %>

 

<jsp:useBean id="now" class="java.util.Date" />
<fmt:formatDate value="${now}" pattern="yyyy-MM-dd hh:mm" var="nowDate" />
<fmt:formatDate value="${now}" pattern="yyyyMMddhhmm" var="nowDateTrim" />
 
 <%
String nowDateTrim = (String)pageContext.getAttribute("nowDateTrim");
out.println(" nowDateTrim = "+ nowDateTrim);
%>

Posted by 홍반장水 홍반장水

댓글을 달아 주세요