반응형

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);
%>

반응형

+ Recent posts