13.2表达式语言-内置对象

发表日期:2015-02-15 21:20:08 | 来源: | | 浏览(727) 分类:JSP基础

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>在此处插入标题</title>

</head>

<body>

<%

pageContext.setAttribute("info", "简单的表达式语句pageContext");

request.setAttribute("info", "简单的表达式语句request");

session.setAttribute("info", "简单的表达式语句session");

application.setAttribute("info", "简单的表达式语句application");

%>

<div>

<h3>${info}</h3>

<p>若不存在info属性默认逐级往下获取pageContext-》request-》session-》application</p>

</div>

<dl>

<dt>分别获得各种对象类型的属性</dt>

<dd>${pageScope.info}</dd>

<dd>${requestScope.info}</dd>

<dd>${sessionScope.info}</dd>

<dd>${applicationScope.info}</dd>

</dl>

<ul>

<li>IP:${pageContext.request.remoteAddr}</li>

<li>SID:${pageContext.session.id}</li>

</ul>

<ul>

<li>接收参数:<%=request.getParameter("ref") %></li>

<li>接收参数:${param.ref}</li>

</ul>

<hr/>

</body>

</html>


集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。