jstl语法

1.scope中数据的调用

在java代码中session.setAttribute("session_member", member); //member为基本数据类型或其封装类或String
${ sessionScope.session_member} 在页面上调用;

如果member为对象;

那么页面调用的时候${ sessionScope.session_membe.属性}

如果member为数组

那么页面调用的时候${ sessionScope.session_membe[index]}

sessionScope 类型还要requestScope(页面调用的时候可以省略)、applicationScope

2.if-else语句实现

<c:choose> 

  <c:when test="">   //if()

   

  </c:when> 

  <c:when test="">   //if()

   

  </c:when> 

  <c:otherwise>   //else{}

  

  </c:otherwise> 

</c:choose> 

3.if判断为空

<c:if test="${empty member}"> //为空

<c:if test="${!empty member}">//不为空

<c:if test="${not empty member}">//不为空

4.forEach序号的调用

<c:forEach var="col" items="${list }" varStatus="status">

${status.index} //索引序号

</c:forEach>

猜你喜欢

转载自wcq881215.iteye.com/blog/2289819