javaWEB-动态网页之el表达式

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'el.jsp' starting page</title>

  </head>
  
  <body>
  
  	<%-- 
  		EL 表达式 就是一个公式 , 该公式里面可以写任何式子代码
  		EL 表达式里面有几个内置对象 
  		pageContext
  		pageScope
  		requestScope
  		sessionScope
  		applicationScope
  		param
  		paramValues
  		initParam
  		Cookie
  		header
  	 --%>
  	
  	<%
  		pageContext.setAttribute("info","Page 范围 ! ");
  		request.setAttribute("info","Request 范围 ! ");
  		session.setAttribute("info","Session 范围 ! ");
  		application.setAttribute("info","Application 范围 ! ");
  		
  		ArrayList list = new ArrayList();
  		pageContext.setAttribute("list",list);
  	%>
  	
  	${ 1 + 1}
  	${ 1==2 ? true : false}
  	<br/>
  	
  	<!-- el 表达式 取 返回中的值 , 从小到大依次取值 . 取第一个出现的值 -->
  	范围取值: ${ pageScope.info } ,
  	${ requestScope.info } ,
  	${ sessionScope.info } ,
  	${ applicationScope.info } ,
  	${ info } 
  	<br/>
  	
  	<!-- 判断对象是否为 空集合 使用 empty 空对象 使用 == null -->
  	${ list == null }
  	${ empty list }
  	<br/>
  	
  	<!-- 获取 地址栏传递过来的参数 -->
  	${ param.test }
  	${ paramValues.n[2] }
  	
  	<!-- 获取 web.xml 项目初始化参数 -->
  	${ initParam.name }
  	<br/>
  	
  	<!-- 获取头信息 -->
  	${ header.host }
  	
  </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值