EL与JSTL笔记小结

EL表达式的使用(5个 问题)
JSTL标签的使用(5个问题)
什么是EL,它能做什么用的?
EL全名为Expression Language在JSP页面使用
格式${一个表达式}
例子${requestScope.customer.id}
功能:
1.才四个域对象中取出属性数据显示


(pageContext.request.session.application)


2.取出请求参数数据显示


<%
request.setAttribute("person",new Person("xfzhanag",18));
%>
Map<String,Person> map=new HashMap<String,Person>();
map.put("A",new Person("AA",12));
map.put(""B",new Person("BB",13));
map.B.age${requestScope.B.age};
map.B.age${requestScope.[‘B‘].age};


${requestScope.person.name};
${requestScope.person[‘name‘]};
List里面的第二个数据
<%


<%
List list=new ArrayList();
list.add("a");
list.add("b");
list.add("c");
request.setAttribute("List",list);


%>


${requestScope.List[1]};
${requestScope.List[‘name‘]};


我的年龄:<requestScope.person.name><br/>
//什么方便?为什么有个中括号?
/*
一种情况?
${requestScope[‘my person‘].name};
map.put("my person",new Person("Xxx",12));


*/
EL能进行的运算?
算数运算(+,-, * ,/ ,%)
关系运算(>,<,==,!=)
逻辑运算(&&,||)
empty运算(判断一个数据是否是空)
(null,空字符串,空集合)
三目条件运算


<%


request.setAttribute("list",new ArrayList());
request.setAttribute("name","");
request.setAttribute("person","new Pseron("Xxx",19));


%>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。