Java Web之EL
阿新 • • 發佈:2019-01-08
<%-- Created by IntelliJ IDEA. User: Vae Date: 2019/1/2 Time: 12:19 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <p>許嵩許嵩</p> <% //JSP的四大作用域 pageContext.setAttribute("msg","pageContext"); request.setAttribute("msg","request"); session.setAttribute("msg","session"); application.setAttribute("msg","application"); %> <h3>獲取每一個作用域中的值</h3> pageContext:<%=pageContext.getAttribute("msg")%><br> request:<%=request.getAttribute("msg")%><br> session:<%=session.getAttribute("msg")%><br> application:<%=application.getAttribute("msg")%><br> <hr> <h3>pageContext的findAttribute方法(只有pageContext才有)</h3> <%=pageContext.findAttribute("msg")%><br> <%=pageContext.findAttribute("msg")==null?"":pageContext.findAttribute("msg")%><br> ${msg}<br> </body> </html>