1.下载JSTL
点击打开链接 下载
2.将jar包放到WEB-INF目录下
3.声明
<%@ taglib prefix="prefix" uri="uri"%>
例如:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4.使用
例:<c:if test="${requestScope.errors !=null}">
应用:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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=ISO-8859-1" charset="utf-8">
<title>Add a product</title>
</head>
<body>
<!-- 错误处理部分 -->
<div id="global">
<c:if test="${requestScope.errors !=null}">
<h5>Error(s)!</h5>
<ul>
<c:forEach var="error" items="${requestScope.errors}">
<li>${error}</li>
</c:forEach>
</ul>
</c:if>
</div>
<div>
<form action="saved1">
<fieldset>
<legend>Add a product</legend>
<table>
<!-- 名称填写表单 -->
<tr>
<td><label>Product name:</label></td>
<td><input name="name" type="text" /></td>
</tr>
<!-- 产品描述 -->
<tr>
<td><label>Product description:</label></td>
<td><input name="description" type="text"/></td>
</tr>
<!-- 产品价格规定 -->
<tr>
<td><label>Product price:</label></td>
<td><input name="price" type="text"></td>
</tr>
</table>
<input type="reset"/>
<input type="submit"/>
</fieldset>
</form>
</div>
</body>
</html>