📄 jsp-el.xtp
字号:
<document> <header> <product>resin</product> <title>JSP EL</title> <version>Resin 3.0</version> <description> <p>JSP EL is a simple expression language for accessing data.</p> </description> </header> <body> <summary/> <s1 title="JSP EL variables"> <p>EL Variables come from one of two places:</p> <ol> <li>implicit variable <deftable> <tr><td>pageContext </td><td> </td></tr><tr><td>pageScope </td><td> </td></tr><tr><td>requestScope </td><td> </td></tr><tr><td>sessionScope </td><td> </td></tr><tr><td>applicationScope </td><td> </td></tr><tr><td>param </td><td> </td></tr><tr><td>paramValues </td><td> </td></tr><tr><td>header </td><td> </td></tr><tr><td>headerValues </td><td> </td></tr><tr><td>cookie </td><td> </td></tr><tr><td>initParam </td><td> </td></tr></deftable> </li><li>pageContext.findAttribute(varname)<br/> which is like getting the first of: <ul> <li>page.getAttribute(varname) </li><li>request.getAttribute(varname) </li><li>session.getAttribute(varname) </li><li>application.getAttribute(varname) </li></ul> </li></ol> <p>So if you have a variable like:</p> <example><% boolean a = true; %> </example> <p>you have to store it as an attribute to make it available as an EL variable:</p> <example><% boolean b = true; pageContext.setAttribute("b",new Boolean(b));%><c:if test="${b}">b is TRUE</c:if> </example> <p>Here is an example that shows this a bit more:</p> <example title="Making values available as JSP EL variables"><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <% boolean a = true; boolean b = true; pageContext.setAttribute("b",new Boolean(b)); boolean c = false; pageContext.setAttribute("c",new Boolean(c)); boolean param = true; pageContext.setAttribute("param",new Boolean(param));%> <%-- this is false because 'a' is not findable by pageContext.findAttribute(varname)--%><c:if test="${'${'}a}">a is TRUE</c:if><c:if test="${'${'}b}">b is TRUE</c:if><%-- this is false because 'c' was set to false --%><c:if test="${'${'}c}">c is TRUE</c:if><%-- This is false because 'param' is an implicit variable which is used instead of pageContext.findAttribute("param")--%><c:if test="${'${'}param}">param is TRUE</c:if> </example> <results>b is TRUE </results> </s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -