JSTL
JSP:JSP Standard Tag Library 。JSP标准标签库
在web目录中导入jstl.jar和standard.jar 包。即可使用
简单JSTL实例
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>JSTL实例</title>
</head>
<body>
<div style="text-align: center">
<c:out value="一个JSTL实例"></c:out>
<br>
<c:out value="<<难于上青天》》"></c:out>
</div>
</body>
</html>
重点:<%@taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>------------引入标签
程序中C:OUT标签是将内容显示到页面中。
if标签
<div style="text-align: center">
<c:if test="${2%2==0}" var="num">
输出为:偶数!!
</c:if>
<br>该数为偶数的检查结果为:
<c:out value="${num}"></c:out>
<c:if test="${3%2!=0}" var="num">
输出为:奇数!!
</c:if>
<br>该数为奇数的检查结果为:
<c:out value="${num}"></c:out>
</div>