<%-- <%@page import="javax.validation.constraints.Null"%>--%>
<%@page import="cn.sxt.model.Address"%>
<%@page import="cn.sxt.model.T_user"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%
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 'index.jsp' starting page</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
int a = 10;
//数据在四大作用域对象中
pageContext.setAttribute("a",a);
request.setAttribute("aaa", true);
session.setAttribute("age", 18);
application.setAttribute("name", "cqm");
//简单对象
T_user user = new T_user(1,"admin","admin","cqm");
request.setAttribute("uuu", user);
//复合对象
T_user u2 = new T_user(2,"admin-cqm","123123","qm", new Address("广东省","广州市","天河区"));
pageContext.setAttribute("u2", u2);
//List中的数据
List list = new ArrayList();
list.add("apple");
list.add("orange");
list.add("watermelon");
list.add("pineapple");
pageContext.setAttribute("fruits", list);
//Map中的数据
Map map = new HashMap();
map.put("name", "zhangsan");
map.put("age", 18);
map.put("gender", "女");
map.put("address", new Address("广东省","广州市","天河区"));
pageContext.setAttribute("person1", map);
//作用域中有相同的key
pageContext.setAttribute("xxx", "pageContext");
request.setAttribute("xxx", "request");
session.setAttribute("xxx", "session");
application.setAttribute("xxx", "application");
T_user uu1 = new T_user(5,"admin","admin","张三");
T_user uu2 = new T_user(5,"admin","admin","张三");
request.setAttribute("uu1", uu1);
request.setAttribute("uu2", uu2);
request.setAttribute("score", 99);
pageContext.setAttribute("a1", null);
pageContext.setAttribute("a2", new ArrayList());
pageContext.setAttribute("a4", "");
%>
尚学堂教育系统,欢迎${user.nickname}
<h3>1、EL表达式从哪里取值?一般情况下,从作用域对象中取值</h3>
${a} ----${aaa} ---- ${age} ---- ${name}
<h3>2、EL表达式可以取什么类型的值?基本数据类型、引用数据类型(对象、复合对象、List、Map)</h3>
${uuu.nickname} ---- ${u2.address.district} ----${fruits[2]} ---- ${person1.address.city}
<h3>3、EL表达式从哪个作用域中取值?默认从最小作用域中开始寻找,找不到往大的作用域中找,都找不到显示为空</h3>
${xxx}
<h3>4、EL从指定作用域中取值?pageScope、requestScope、sessionScope、applicationScope</h3>
${pageScope.xxx} ---- ${requestScope.xxx} ---- ${sessionScope.xxx } ---- ${applicationScope.xxx}
<h3>5、EL表达式还可以取请求参数中的值:param、paramValues</h3>
${param.username} ---- ${paramValues.fav[2]}
<h3>6、EL表达式除了"."操作符之外,还有"[]"操作符:"[]"可以解析子EL表达式</h3>
${uuu["nickname"]} ---- ${param.type} ---- ${uuu[param.type]}
<h3>7、EL表达式中的为空判断:empty判断为空的有:空字符串、null、空集合、空map</h3>
${empty a1} ---- ${empty a2} ---- ${empty a3} ---- ${empty a4}
<h3>8、EL表达式可以进行一些基本的数学运算</h3>
${5+4} ---- ${5-4} ---- ${5*4} ----${5/4} ---- ${5%4} ----${5+"4"}
<h3>9、EL表达式可以进行一些逻辑判断</h3>
${5>4} ---- ${5==4} ---- ${5 eq 4} --- ${uu1==uu2} --- ${uu1 eq uu2} ---- ${score==99}
</body>
</html>