EL表达式没有指定范围,从最小范围开始
<%
pageContext.setAttribute("shxt", "java web");
request.setAttribute("shxt", "呀呀呀");
session.setAttribute("shxt", "丫丫丫");
application.setAttribute("shxt", "呐呐呐");
%>
<h1>${shxt }</h1>
<h2>获取上面所有数据:</h2>
<h3>pageContext:${pageScope.shxt }</h3>
<h3>request:${requestScope.shxt }</h3>
<h3>session:${sessionScope.shxt }</h3>
<h3>application:${applicationScope.shxt }</h3>
<h2>数组方式获取:</h2>
<%
pageContext.setAttribute("com.user", "琅琊榜");
request.setAttribute("com.user", "梅长苏");
%> <h3>pageContext:${pageScope["com.user"] }</h3>
<h3>request:${requestScope["com.user"] }</h3>
list和map取值
<%
Student stu = new Student();
stu.setName("悟空");
stu.setSchool("西游");
request.setAttribute("stu",stu);
%>
${stu.name }--${stu["name"] }--${stu.getName() }
<h1>list取值</h1>
<%
List<Student> list = new ArrayList<Student>();
list.add(stu);
request.setAttribute("list",list);
%>
${list[0].name }
<h1>map取值</h1>
<%
Map<String,Student> map = new HashMap<String,Student>();
map.put("stu",stu);
request.setAttribute("map",map);
%>
${map.stu.name }
empty判断
<h2>empty(判断是否存在):${empty dddd }</h2>
获取项目根路径--记忆
${pageContext.request.contextPath }
特殊字符
空格
©
®
<
>
&
总结
身心俱佳情况下学习最好,笑口常开菜包子