JSTL&EL

一、EL表达式 (封装了get方法,没有set功能)
1.作用:取JSP四大作用域中的属性值
setArrtibute("key",value)
${key}: <%=getAttribute("key")%>
2.语法: ${属性名}
. 访问属性 getAttribute() getXX() getValue("key")
["属性名"] list[0] map['key']
3.隐式对象
四大作用域对象:依次从小到大匹配符合要求的属性值,没找到返回null
pageScope 当前页面
requestScope 当前请求
sessionScope 当前会话
applicationScope 当前Web应用上下文
参数
param param.username getParameter("username")
paramValues getParameterValues("参数名")
4.运算
1.算术运算 ${num + 1} ${num}
2.比较运算
== eq
!= ne
< lt
> gt
>= ge
<= le
3.逻辑运算
&& and
|| or
! not
4.判断null值
empty 0 "" null 为true
二、JSTL标签
1.作用:简化java代码,封装逻辑控制、循环迭代、数据格式化
2.使用条件:
1.jstl.jar 导入项目 WEB-INF/lib
2.jsp页面导入标签库
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
3.if test="条件表达式"
4、choose if...else if ..else
5.foreach
<c:foreach items="遍历的数据" var="name 每次循环的变量名" >
${name}
</c:foreach>

 

posted @ 2018-12-02 16:46  赏景缘途  阅读(88)  评论(0编辑  收藏  举报