b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

el表达式_ognl表达式和el表达式_el表达式用法(2)

电脑杂谈  发布时间:2017-01-21 08:17:00  来源:网络整理

${pageContext.request.queryString}
Scope对象

pageScope,requestScope,sessionScope,applicationScope变量用来访问存储在各个作用域层次的变量。

举例来说,如果您需要显式访问在applicationScope层的box变量,可以这样来访问:applicationScope.box。

param和paramValues对象

param和paramValues对象用来访问参数值,通过使用request.getParameter方法和request.getParameterValues方法。

举例来说,访问一个名为order的参数,可以这样使用表达式:${param.order},或者${param["order"]}。

接下来的例子表明了如何访问request中的username参数:

<%@ page import="java.io.*,java.util.*" %>
<%
    String title = "Accessing Request Param";
%>
<html>
<head>
<title><% out.print(title); %></title>
</head>
<body>
<center>
<h1><% out.print(title); %></h1>
</center>
<div align="center">
<p>${param["username"]}</p>
</div>
</body>
</html>

param对象返回单一的字符串,而paramValues对象则返回一个字符串数组。el表达式

header和headerValues对象

header和headerValues对象用来访问信息头,通过使用 request.getHeader方法和request.getHeaders方法。

举例来说,要访问一个名为user-agent的信息头,可以这样使用表达式:${header.user-agent},或者${header["user-agent"]}。

接下来的例子表明了如何访问user-agent信息头:

<%@ page import="java.io.*,java.util.*" %>
<%
    String title = "User Agent Example";
%>
<html>
<head>
<title><% out.print(title); %></title>
</head>
<body>
<center>
<h1><% out.print(title); %></h1>
</center>
<div align="center">
<p>${header["user-agent"]}</p>
</div>
</body>
</html>

运行结果如下:

header对象返回单一值,而headerValues则返回一个字符串数组。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-27770-2.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    每日福利
    热点图片
    拼命载入中...