19-撩課JavaWeb之EL表示式詳解

什麼是EL表示式
EL(Express Lanuage)表示式 可以嵌入在jsp頁面內部 減少jsp指令碼的編寫 EL出現的目的是要替代jsp頁面中指令碼的編寫。

作用
EL最主要的作用是獲得四大域中的資料 從四大域當中取資料 pageContext ${pageScope.key}; request ${requestScope.key} session ${sessionScope.key} application ${applicationScope.key} 簡寫 ${EL表示式} EL從四個域中獲得某個值${key} 依次從pageContext域, request域,session域, application域中獲取屬性 在某個域中獲取後將不在向後尋找


EL內建11物件
pageScope 獲取JSP中pageScope域中的資料 requestScope 獲取JSP中requestScope域中的資料 sessionScope 獲取JSP中sessionScope域中的資料 applicationScope 獲取JSP中applicationScope域中的資料 param request.getParameter() paramValues rquest.getParameterValues() header request.getHeader(name) headerValues request.getHeaderValues() initParam this.getServletContext().getInitParameter(name) cookie request.getCookies()---cookie.getName()---cookie.getValue() pageContext pageContext獲得其他八大物件 獲取當前專案的名稱 ${pageContext.request.contextPath}

EL執行表示式
內部可以進行運算,只要有結果 ${1+1} ${empty user} ${user==null?true:false}

如果你想要獲取Xmind思維導圖源件加群:869866610,進群可以獲取以上技術的學習視訊。