Eclipse+Tomcat下配置JSTL



Eclipse+Tomcat下配置JSTL

Eclipse+Tomcat下配置JSTL(寒风情  08年5月)

第一步:下载支持JSTL的文件。jakarta-taglibs-standard-1.1.2.zip

第二步:下载解压后的两个jar文件:standard.jar和jstl.jar文件拷贝到工程的\WEB-INF\lib\下

第三步:并且把解压后的tld文件夹里面的所有文件复制到工程的WEB-INF文件夹下面。

第四步:修改\WEB-INF\下的web.xml文件。

             web.xml需要修改添加的内容为:

<taglib>
   <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
   <taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
   <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
   <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
   <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
   <taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
   <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
   <taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>

<taglib>
   <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
   <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
</taglib>

========================================================================

重要提示:有些 web.xml  的视图化编辑不加<jsp-config/>的话认不出 lib  的内容.   所以有可能需要包含在

  标记中。,<jsp-config/>标签并不是必备标签.不过一般加上为妙。

========================================================================

第五步:测试


修改index.jsp内容为:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>

<%@ page contentType=”text/html;charset=GB2312″ %>

<%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%>

<html>

<head>

<title>测试你的第一个使用到JSTL 的网页</title>

</head>

<body>

<c:out value=”欢迎测试你的第一个使用到JSTL 的网页”/>

</br>你使用的浏览器是:</br>

<c:out value=”${header['User-Agent']}”/>

<c:set var=”a” value=”David O’Davies” />

<c:out value=”David O’Davies” escapeXml=”true”/>

</body>

</html>

最后开启tomcat,进行调试,我的输出结果是

欢迎测试你的第一个使用到JSTL 的网页
你使用的浏览器是:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) David O’Davies

http://blog.sina.com.cn/s/blog_4e1b13bb0100awgb.html