JSTL 设置

在tomcat5.0 JSTL还需要自已配置
虽然JSTL计划捆绑到下一波Web容器中,但您目前必须自己进行设置。按以下步骤操作以将JSTL装载到Web容器中
1.从 apache.org下载 jakarta-taglibs-standard-current.tar.gz 。
2.解压缩下载的文件。
3.将 jakarta-taglibs/standard-1.0.3/tld/c.tld 拷贝到 WEB/INF/tlds 目录。
4.将 jakarta-taglibs/standard-1.0.3/lib 中的所有JAR文件拷贝到 WEB-INF/lib 目录。
5.将以下显示的条目添加到 WEB-INF/web.xml 部署描述符中。
<taglib>
  <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
  <taglib-location>/WEB-INF/tlds/c.tld</taglib-location>
</taglib>

6.重启Web容器。
联合 JSTL标记
如果您希望在JSP页面上使用任何JSTL标记,您首先必须在该页面上声明标记库前缀和URL。我们正在使用核心JSTL库,因此使用的标准前缀是 c (代表 核心)。显示增加了 taglib 指令的Web站点索引文件:
<%@ 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 标记。

<%@ 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>

你可能感兴趣的:(java,C++,Web,jsp,C#)