EL表达式的 11 个隐含对象

一、EL表达式的 11 个隐含对象

在这里插入图片描述

二、EL获取四个特定域中的属性

<body>
<%
    pageContext.setAttribute("key1", "pageContext1");
    pageContext.setAttribute("key2", "pageContext2");
    request.setAttribute("key2", "request");
    session.setAttribute("key2", "session");
    application.setAttribute("key2", "application");
%>
${pageScope.key1}
${requestScope.key2}
${sessionScope.key2}
${applicationScope.key2}
</body>

三、pageContext对象的使用

<%--jsp的方法--%>

<%=request.getScheme()%>
<%=request.getServerName()%>
<%=request.getServerPort()%>
<%=request.getContextPath()%>
<%=request.getMethod()%>
<%=request.getRemoteHost()%>
<%=session.getId()%>

<%--EL的方法 --%>

<%--1. 协议: --%>
${pageContext.request.scheme}
<%--2. 服务器 ip: --%>
${pageContext.request.serverName}
<%--3. 服务器端口: --%>
${pageContext.request.serverPort}
<%--4. 获取工程路径: --%>
${pageContext.request.contextPath}
<%--5. 获取请求方法: --%>
${pageContext.request.method}
<%--6. 获取客户端 ip 地址: --%>
${pageContext.request.remoteHost}
<%--7. 获取会话的 id 编号:--%>
${pageContext.session.id}

四、EL表达式其他隐含对象的使用

输出请求参数 username 的值:${ param.username } 
输出请求参数 password 的值:${ param.password } 

输出请求参数 username 的值:${ paramValues.username[0] } 
输出请求参数 hobby 的值:${ paramValues.hobby[0] }
输出请求参数 hobby 的值:${ paramValues.hobby[1] } 


输出请求头【User-Agent】的值:${ header['User-Agent'] } 
输出请求头【Connection】的值:${ header.Connection }
输出请求头【User-Agent】的值:${ headerValues['User-Agent'][0] } 

获取 Cookie 的名称:${ cookie.JSESSIONID.name } 
获取 Cookie 的值:${ cookie.JSESSIONID.value } 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值