EL隐含对象:
1、与范围有关的隐含对象
applicationScope
sessionScope
requestScope
pageScope
2、与输入有关的隐含对象
param
paramValues
3、其它隐含对象
cookie
header
headerValues
initParam
pageContext
使用方法:
<%@page import="java.util.ArrayList"%><%@page import="java.util.List"%><%@page import="com.atguigu.javaweb.Customer"%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>Insert title here ${param.score > 60 ? "及格" : "不及格" } <% Listnames = new ArrayList (); names.add("abc"); request.setAttribute("names", names); %> names is empty: ${empty requestScope.names } pageContext: pageContext 即为 PageContext 类型, 但只能读取属性就可以一直的 . 下去。 contextPath: ${pageContext.request.contextPath } sessionId: ${pageContext.session.id } sessionAttributeNames: ${pageContext.session.attributeNames } initParam: ${initParam.initName } Accept-Language: ${header["Accept-Language"] } JSESSIONID: ${cookie.JSESSIONID.name } -- ${cookie.JSESSIONID.value } score: ${param.score } <%-- <%= request.getParameter("score") %> --%> names: ${paramValues.name[0].class.name } <%-- <%= request.getParameterValues("name")[0].getClass().getName() %> --%> time: ${applicationScope.time.time } <%-- <%= application.getAttribute("time") %> --%> score: ${param.score + 11} score: <%= request.getParameter("score") + 11 %> <% Customer cust2 = new Customer(); cust2.setAge(28); request.setAttribute("customer", cust2); %> age: ${customer.age } age: ${sessionScope.customer["age"] } <%-- Customer customer = (Customer)session.getAttribute("customer"); out.print(customer.getAge()); --%> <% Customer customer = new Customer(); customer.setName("com.qimeng"); session.setAttribute("com.qimeng", customer); %> name: ${sessionScope["com.atguigu.customer"].name }