JSTL全名为JavaServer Pages Standard Tag Library,是由JCP(Java Community Process)所制定的标准规范,它主要提供给Java Web开发人员一个标准通用的标签函数库。
Web程序员能够利用JSTL和EL来开发Web程序,取代传统直接在页面上嵌入Java程序(Scripting)的做法,以提高程序的阅读性、维护性和方便性。

一、引入标签库

下载地址:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/

在 Tomcat 的工作目录,也就是安装目录下的 webapps/Root 目录下,新建一个 WEB-INF 文件夹,并在 WEB-INF 文件夹下新建一个 lib 文件夹,然后把下载下来的压缩包中 lib 文件夹中的 standard.jar 和 jstl.jar 复制到该 lib 文件夹中,接下来把压缩包中整个 tld 文件夹复制到 WEB-INF 文件夹下。在 WEB-INF 文件夹中的 web.xml 中修改(如果没有,新建一个):

<?xml version="1.0" encoding="utf-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5">

  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>
  
  <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
        <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
        <taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
        <taglib-location>/WEB-INF/tld/x.tld</taglib-location>
    </taglib>

</web-app>
View Code

相关文章:

  • 2021-04-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2021-10-13
猜你喜欢
  • 2022-12-23
  • 2021-10-04
  • 2021-11-06
  • 2021-10-16
  • 2021-12-05
相关资源
相似解决方案