zoukankan      html  css  js  c++  java
  • JSP TAG

    Jsp tag 能够灵活的将公共JSP代码模块化,类似<jsp:include page="./include.jsp"></jsp:include>等等。

    我们自己定义的JSP模块代码可能在引用时会依据不同的引用场景,须要显示的内容略有不同,这时使用JSP.INCLUDE就不能满足我们的需求了。

    因此,我们能够使用JSP tag 的方式实现。

    第一步

    在WEB-INF/tags文件夹下创建 demo.tag 文件

    代码例如以下:

    <%@tag pageEncoding="UTF-8" isELIgnored="false" body-content="empty"%>

    <!--  定义引用时必要的属性 (可选)-->

    <%@ attribute name="type" required="true" rtexprvalue="true" %>

    this jsp tag content type:<%=this.type %>


    第二步  使用该TAG

    我们仅仅须要在使用的JSP 头部引入该Tag 

    <%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>

    其次在须要输出TAG信息的地方使用

    <tags:demo type="test"/>


    完毕。



  • 相关阅读:
    浮动
    导航
    Json
    节点
    评论框
    WebClient 指定出口 IP
    IIS8 下 JS, CSS 等静态文件出现 500 错误
    使用 ffmpeg 转换 mov 视频
    使用 ildasm 和 ilasm 修改程序集的的引用信息
    2020-01-08 工作日记:无题
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4493851.html
Copyright © 2011-2022 走看看