zoukankan      html  css  js  c++  java
  • JSP--JSTL(JSP标准标签库)

    JSP--JSTL(JSP标准标签库)

    博客说明

    文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢!

    概念

    JavaServer Pages Tag Library JSP标准标签库

    是由Apache组织提供的开源的免费的jsp标签

    作用

    用于简化和替换jsp页面上的java代码

    安装

    菜鸟教程文档地址 https://www.runoob.com/jsp/jsp-jstl.html

    下载地址

    下载 jakarta-taglibs-standard-1.1.2.zip 包并解压,将 jakarta-taglibs-standard-1.1.2/lib/ 下的两个 jar 文件:standard.jarjstl.jar 文件拷贝到 /WEB-INF/lib/ 下。

    将 tld 下的需要引入的 tld 文件复制到 WEB-INF 目录下。

    接下来我们在 web.xml 文件中添加以下配置:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" 
        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">
        <jsp-config>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
        <taglib-location>/WEB-INF/fmt.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/fmt-rt</taglib-uri>
        <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/c.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/core-rt</taglib-uri>
        <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
        <taglib-location>/WEB-INF/sql.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/sql-rt</taglib-uri>
        <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/x</taglib-uri>
        <taglib-location>/WEB-INF/x.tld</taglib-location>
        </taglib>
        <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/x-rt</taglib-uri>
        <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
        </taglib>
        </jsp-config>
    </web-app>
    

    使用步骤

    1. 导入jstl相关jar包

    2. 引入标签库:taglib指令:

      <%@ taglib %>
      
    3. 使用标签

    常用的JSTL标签

    if--相当于java代码的if语句
    1. 属性:

      • test 必须属性,接受boolean表达式
        • 如果表达式为true,则显示if标签体内容,如果为false,则不显示标签体内容
        • 一般情况下,test属性值会结合el表达式一起使用
    2. 注意:

      • c:if标签没有else情况,想要else情况,则可以在定义一个c:if标签
    choose--相当于java代码的switch语句
    1. 使用choose标签声明 相当于switch声明
    2. 使用when标签做判断 相当于case
    3. 使用otherwise标签做其他情况的声明 相当于default
    foreach--相当于java代码的for语句

    感谢

    菜鸟教程

    黑马程序员

    万能的网络

    以及勤劳的自己
    关注公众号: 归子莫,获取更多的资料,还有更长的学习计划

  • 相关阅读:
    h5页面 禁止缩放
    Mac 建立自己的服务器,支持PHP
    socket(孔、插座 --> 套接字) Socket通信 -- 了解
    核心动画
    popoverPresentationController UIPopoverController 使用方法详解(气泡控制器)
    plist中的中文数据
    Attempt to present <vc> on <vc> which is already presenting <vc>/(null)
    Xcode 8 : iOS xib is missing from working copy、iOS misssing file
    Xcode 中的黄色文件夹/蓝色文件夹
    iOS 容器 addChildViewController
  • 原文地址:https://www.cnblogs.com/guizimo/p/13202165.html
Copyright © 2011-2022 走看看