欢迎访问:常州市武进区嘉泽中心小学网站 !今天是:
栏目列表
您现在的位置是:首页>>教师>>计算机技术>>网站制作技术>>文章内容
在Tomcat中安装JSTL
发布时间:2008-11-20   点击:   来源:本站原创   录入者:佚名
 

前提 OS: WIN2000
     tomcat已经配置好(tomcat可以到 下载)
开始实战啦
1.准备jstl
   到下载jakarta-taglibs-standard-current.zip
解压后成为jakarta-taglibs-standard-1.1.1

2.准备web开发目录
   比如我的web目录为h:\webapp\myweb\(当然可以把你的web应用放在%tomcat_home%\webapps\),称为工作目录Working folder,在工作目录h:\webapp\myweb\下建立WEB-INF\lib,WEB-INF\classes

3.拷贝.jar文件
   将jakarta-taglibs-standard-1.1.1\lib\下的两个jar文件:standard.jar和jstl.jar文件拷贝到\WEB-INF\lib\下

4.拷贝.tld文件
 将jakarta-taglibs-standard-1.1.1\tld\下的8个tld类型文件拷到"Working folder\WEB-INF\"下

5.在\WEB-INF\下建立web.xml文件:
  <?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns=""
    xmlns:xsi="http://{域名已经过期}/2001/XMLSchema-instance"
    xsi:schemaLocation=" /web-app_2_4.xsd"
    version="2.4">
 
  <taglib>
    <taglib-uri>http://{域名已经过期}/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/fmt-rt</taglib-uri>
    <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/core-rt</taglib-uri>
    <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/sql</taglib-uri>
    <taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/sql-rt</taglib-uri>
    <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/x</taglib-uri>
    <taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://{域名已经过期}/jstl/x-rt</taglib-uri>
    <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
</taglib>
</web-app>
6.建立一个名为test.jsp文件
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html;charset=GB2312" %>
<%@ taglib prefix="c" uri="http://{域名已经过期}/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>

7.开启tomcat,进行调试,我的输出结果是

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

注:如果你的tld文件个数为15个,在上面的web.xml中<taglib-location>中更改。如果想要请和我联系
cnsdl@{域名已经过期}


附件:
    关闭窗口
    打印文档
    账号登录
    保持登录 忘记密码?
    账号与武进教师培训平台同步