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>
  • 相关阅读:
    切割自动贴标机功能、原理与常见问题回答
    WINCE中蓝牙扫描模块现10050,控制器无法找到错误的解决思路
    在WINCE中基于ActiveSync的Socket通信 c#
    cs关于房间分配
    JS判断单、多张图片加载完成
    在网站中添加 React
    tcp读取数据的方法
    微软发布2011年耐用消费品行业微软CRM解决方案 一方水土
    Microsoft Dynamics CRM4.0介绍 一方水土
    徐工集团再度携手瑞泰搭建Call Center管理平台 一方水土
  • 原文地址:https://www.cnblogs.com/wujixing/p/5010818.html
Copyright © 2011-2022 走看看