JSTL config 4 step

1.將standard.jarjstl.jar文件拷貝到/WEB-INF/lib/

2.將jakarta-taglibs-standard-1.1.1/tld/下的tld類型文件拷到"/WEB-INF/tlds"下(1.1是15個文件,1.0是8個)

3.在/WEB-INF/web.xml文件中:(以下<taglib>定義是針對1.0的)
  <?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
 
  <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/tlds/fmt.tld</taglib-location>
</taglib>

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

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

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

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

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

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

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

4. 建立一個名爲test.jsp文件
<%@   page   isELIgnored="false"  %>Tomcat中必須加這行,因爲,默認jsp是不支持EL的.Weblogic中不能加,加了會出錯!
<!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>

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章