EL表达式2

来源:互联网 发布:石油骚动mac版中文 编辑:程序博客网 时间:2024/06/08 04:43
 

EL的内置对象:

(1)pageScope、requestScope、sessionScope、applicationScope

通知JSP引擎调用pageContext.findAttribute()方法,以标识符为关键字从各个域对象中获取对象。如果域对象中不存在标识符所对应的对象,则返回结果为“”(注意,不是null)。

(2)param  paramValues

request.getParameter(String name)

request.getParameterValues(String name)

在EL中则可以使用param和paramValues两者来取得数据:

${param.name}

${paramValues.name}

(3)cookie、session、

(4)header和headerValues

读取请求的头数据,使用header或headerValues内置对象,例如${header[“User-Agent”]},headerValues则用来取得所有的头信息,等价于调用request.getHeaders()方法。

(5)initParam

initParam用来读取设置在web.xml中的参数值。

${initParam.repeat}== (String)application.getInitParameter(“repeat”);

(6)pageContext

pageContext用于取得其他有关用户要求或页面的详细信息

${pageContext.request.queryString} 取得请求的参数字符串

${pageContext.request.requestURL} 取得请求的URL,不包括参数字符串

${pageContext.request.contextPath}         服务的web application 的名称

${pageContext.request.method}           取得HTTP 的方法(GET、POST)

${pageContext.request.protocol}         取得使用的协议(HTTP/1.1、HTTP/1.0)

${pageContext.request.remoteUser}         取得用户名称

${pageContext.request.remoteAddr }         取得用户的IP 地址

${pageContext.session.new}             判断session 是否为新的

${pageContext.session.id}               取得session 的ID

${pageContext.servletContext.serverInfo}   取得主机端的服务信息

在JSP 2.0中默认是启用EL表达式的,但如果在JSP页面中使用了与JSP EL标记符相冲突的其他技术,可以通过使用page指令的isELIgnored属性来忽略JSP EL的标识符。

<%@page isELIgnored="true|false"%>

true:表示忽略对EL表达式进行计算。

false:表示计算EL表达式。

isELIgnored默认为false。

还可以修改web.xml来决定当前的web应用不使用JSP EL。

<jsp-config>

     <jsp-property-group>

            <url-pattern>*.jsp</url-pattern>

            <el-ignored>true</el-ignore>

     </jsp-property-group>

</jsp-config>

Web.xml中的<el-ignored>标记用来预设所有JSP网页是否使用JSP EL,如果web.xml和page制定都进行了设定,page指令的设定优先级要高。
原创粉丝点击