重启Web容器。
这是JSTL设置的速成版本,它可以满足大多数情况。更详细信息请参阅 参考资料部分。
联合JSTL标记
如果您希望在JSP页面上使用任何JSTL标记,您首先必须在该页面上声明标记库前缀和URL。我们正在使用核心JSTL库,因此使用的标准前缀是 c (代表 核心)。表1显示增加了 taglib 指令的Web站点索引文件:
表1:索引文件的taglib指令
﹤%@ page language="java" contentType="text/html" %﹥ ﹤%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %﹥ ﹤html﹥ ﹤head﹥ ﹤title﹥newInstance.com﹤/title﹥ ﹤meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /﹥ ﹤link href="/styles/default.css" rel="stylesheet" type="text/css" /﹥ ﹤/head﹥ ﹤body﹥ ﹤jsp:include page="header.jsp" flush="true"﹥ ﹤jsp:param name="pageTitle" value="newInstance.com"/﹥ ﹤jsp:param name="pageSlogan" value=" " /﹥ ﹤/jsp:include﹥ ﹤%@ include file="/navigation.jsp" %﹥ ﹤jsp:include page="bookshelf.jsp" flush="true" /﹥ ﹤jsp:include page="/mt-blogs/index.jsp" flush="true" /﹥ ﹤%@ include file="/footer.jsp" %﹥ ﹤/body﹥ ﹤/html﹥ |
在向JSP页面添加了JSTL taglib之后,您可以使用核心库中的任何标记,只需把标记的前缀改为 c 。为了了解这一流程,我们将尝试把页面从 jsp:include 标记转换成 c:import 标记。 表2显示了本系列第二部分介绍的 jsp:include 实例(见 参考资料)转为使用新 c:import 标记。
表2:转为JSTL
﹤%@ page language="java" contentType="text/html" %﹥ ﹤%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %﹥ ﹤html﹥ ﹤head﹥ ﹤title﹥newInstance.com﹤/title﹥ ﹤meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /﹥ ﹤link href="/styles/default.css" rel="stylesheet" type="text/css" /﹥ ﹤/head﹥ ﹤body﹥ ﹤jsp:include page="header.jsp" flush="true"﹥ ﹤jsp:param name="pageTitle" value="newInstance.com"/﹥ ﹤jsp:param name="pageSlogan" value=" " /﹥ ﹤/jsp:include﹥ ﹤%@ include file="/navigation.jsp" %﹥ ﹤c:import url="bookshelf.jsp" /﹥ ﹤c:import url="/mt-blogs/index.jsp" /﹥ ﹤%@ include file="/footer.jsp" %﹥ ﹤/body﹥ ﹤/html﹥ |
- 在JDBC设计中加速JSP访问数据库
- 对比JSP和ASP.NET的存储过程
- JSP和IIS的最佳解决方案实例分析
用户点评