jsp 內置對象
-
內置對象又叫隱藏對象 ,隱含對象 ,隱式對象
-
request(jsp中域模型對象)
-
session(jsp中域模型對象)
-
response
-
application(jsp中域模型對象)
-
out
-
exception
-
page
-
pageContext(jsp中域模型對象)
-
config
-
jsp 導包
-
先導包,然後在對應的文件內填寫如下內容
-
java
-
<%@ page import="">
-
-
jstl
-
<%@ taglib uri="http://java.sum.com/jsp/jstl/core" prefix="c">
-
EL表達式
-
定義: expression language
-
作用: ${EL表達式} 等價於findAttribute(name)
-
分類
EL表達式 | 含義 |
---|---|
${pageScope.user}<==>pageContext.getAttriute("user"); | 當前頁面的域模型對象 (jsp特有) |
${requestScope.user}<==>request.getAttriute("user"); | request 的域模型對象 作用範圍只在 當前這次請求當中 |
${ sessionScope.user}<==>session.getAttriute("user"); | session的域模型對象 作用範圍在session的生命週期當中 |
${applicationScope.user}<==>servletContext.getAttriute("user"); | servletContext 域模型對象 作用範圍在整個應用服務的時間當中 |
${page}<==>pageContext.findAttribute("user"); | --- |
-
注:
${page}
-
${pageScope.user }-->${ requestScope.user}-->${ sessionScope.user}-->${applicationScope.user}
pageContext
操作其它域對象的方法 (增刪改)
void setAttribute(String name,Object o,int Scope);
Object getAttribute(String name,intScope);
void removeAttribute(String name,intScope);
參數值
PageContext.PAGE_SCOPE
PageContext.REQUEST_SCOPE
PageContext.SESSION_SCOPE
PageContext.APPLICATION_SCOPE
findAttribute(Stringname)
自動從page,request ,session ,application依次查找,找到了就取值,結束查找(作用域的範圍由小到大)