JSTL

来源:互联网 发布:淘宝店铺欢迎语幽默 编辑:程序博客网 时间:2024/05/29 07:00

一、EL表达式

(1) 取普通属性
 ${属性名称}
 
(2) 对应查找范围:
 page --> request-->session-->application
 对应:
 ${pageScope.属性}--> ${requestScope.属性}--> ${sessionScope.属性}--> ${applicationScope.属性}
 
(3) 接收参数
 单一参数:${param.参数名}
 一组参数: ${paramValues.参数名[1]}
 
(4)集合
 List
 List users =new ArrayList();
 request.setAttribute("users", users);
 ${users[0]}
 
 Map
 Map map =new HashMap();
 map.put("m1","m1");
 map.put("m2","m2");
 request.setAttribute("users", map);
 ${users["m1"]} || ${users.m1}
 
(5)对象
 ${对象.属性}
 
(6)运算符
 ${empty info} 判断是否为空
 
二、JSTL

 <c:out value="hello" default="默认内容"></c:out>
 
 <c:set var="属性名称" target="目标属性" property="属性名称" scope="默认是page">

 <c:remove var="" scope=""/>
 
 <c:catch var />
 
 <c:if test="${param.ref=='xxx'}" var="res1" scope="默认page">
  
 </c:if>
 
 <c:choose>
  <c:when test="${num==2}">   
  </c:when> 
  <c:otherwise>
  </c:otherwise>
 </c:choose>
 
 List
 <c:forEach items="集合名称" var="变量">
  ${变量}
 </c:forEach>
 
 Map
 <c:forEach items="集合名称" var="变量">
  ${变量.key} ${变量.value}
 </c:forEach>
 
 
 

原创粉丝点击