zoukankan      html  css  js  c++  java
  • JSP标准标签库(JSTL)--JSTL简介与安装

    对于MVC设计模式来讲,我们一直强调,在一个JSP钟scriptlet代码越少越好,但是只靠以前的概念很难实现,因为标签的开发特别麻烦,所以为了简化标签,也为了让标签更具备一些通用性,所以一般在开发中(不使用框架前提下),可以使用JSTL组件完成开发的任务。

    JSTL:JSP Standard Tag Library,JSP标准标签库。

    开发环境:JDK1.6, Tomcat6.0,来说,JSTL的稳定版本是1.2

    下载下来jstl-1.2.jar,里面主要有以下标签库分类:

    1. c.tld: 核心标签库 , 定义了属性管理,迭代,判断,输出

    2. sql.tld:sql标签库 ,定义了查询数据库操作

    3. x.tld:XML标签库,用于操作XML数据

    4. fn.tld:函数标签库,提供了一些常用的操作函数,例如:字符串函数

    5. fmt.tld:I18N格式标签库, 格式化数据

    可以直接从jar包中取出来,放入工作目录D:WorkspaceWEB-INF里

    然后把jar包放入 D:apache-tomcat-7.0.57lib里。

    验证jsp:

    <%@ page contentType="text/html" pageEncoding="GBK"%>
    <%--@ taglib prefix="c" uri="/WEB-INF/c.tld"--%>
    <%@ taglib prefix="c" uri="http://www.mldn.cn/jst/core"%>
    <html>
    <head><title>www.mldnjava.cn,MLDN高端Java培训</title></head>
    <body>
        <h3><c:out value="Hello MLDN!!!"/></h3>
    </body>
    </html>

    此标签就等同于完成一个属性=out.println()。

    web.xml设置的话,就可以将第二行替换成第三行

        <jsp-config>
            <taglib>
                <taglib-uri>http://www.mldn.cn/jst/core</taglib-uri>
                <taglib-location>/WEB-INF/c.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://www.mldn.cn/jst/fmt</taglib-uri>
                <taglib-location>/WEB-INF/fmt.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://www.mldn.cn/jst/fn</taglib-uri>
                <taglib-location>/WEB-INF/fn.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://www.mldn.cn/jst/sql</taglib-uri>
                <taglib-location>/WEB-INF/sql.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://www.mldn.cn/jst/x</taglib-uri>
                <taglib-location>/WEB-INF/x.tld</taglib-location>
            </taglib>
        </jsp-config>
  • 相关阅读:
    一个意外错误使你无法删除该文件,文件或目录损坏且无法读取(转)
    测验3: 基本数据类型 (第3周)-程序题
    Oracle深入学习
    自动化测试
    时尚随感
    SQL-使用事务删除重复记录行
    HDU1878欧拉回路
    简单的完全背包HDU1114
    简单的背包变形HDU1203,HDU2955
    简单的背包问题(入门)HDU2602 HDU2546 HDU1864
  • 原文地址:https://www.cnblogs.com/wujixing/p/5010818.html
Copyright © 2011-2022 走看看