[JSTL]c:ifでセッションスコープの変数を判定するサンプル

書式
session.setAttribute(変数名,値)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<%
session.setAttribute("userName","admin");
%>
<c:if test="${userName == 'admin'}" var="st" />
<c:if test="${st}" >
AAA
</c:if>
<c:if test="${!st}" >
BBB
</c:if>
<% session.setAttribute("userName","admin"); %> <c:if test="${userName == 'admin'}" var="st" /> <c:if test="${st}" > AAA </c:if> <c:if test="${!st}" > BBB </c:if>
<%
session.setAttribute("userName","admin");
%>

<c:if test="${userName == 'admin'}" var="st" />

<c:if test="${st}" >
AAA
</c:if>

<c:if test="${!st}" >
BBB
</c:if>

 

JSTL

Posted by arkgame