<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*"%>
<%-- 引入JSTL核心标签库 --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%-- 使用JSTL 导入JSTL的jar包 jstl-1.2.jar standard-1.1.2.jar--%>
<%
List list = new ArrayList();
list.add("0");
list.add("1");
list.add("2");
list.add("3");
list.add("4");
list.add("5");
request.setAttribute("list",list);
%>
<%--
JSTL 运算符汇总
算术运算符 + 、 - 、 * 、 / (或 div )和 % (或 mod )
关系运算符 == (或 eq )、 != (或 ne )、 < (或 lt )、 > (或 gt )、 <= (或 le )和 >= (或 ge )
逻辑运算符 && (或 and )、 || (或 or )和 ! (或 not )
验证运算符 empty
--%>
<%-- forEach 循环遍历 --%>
<c:forEach var="str" items="${list}">
<c:if test="${str ge 3}">
${str}
</c:if>
</c:forEach>
<br/>
<c:forEach var="str" items="${list}">
<c:if test="${str eq 5}">
${str}
</c:if>
</c:forEach>
<br/>
<c:forEach var="str" items="${list}">
<c:if test="${str le 3}">
${str}
</c:if>
</c:forEach>
</body>
</html>
JSP JSTL core标签库
最新推荐文章于 2019-08-16 17:18:31 发布