• jsp中的include静态包含与动态包含,


    d动态包含与静态包含的最大区别是 

    静态包含:<%@ include file = "文件名.jsp"%>,在<body>的标签外定义。在没有编译的时候,两个java文件都已经包含起来了(合并成一个)。

    动态包含:<%jsp:include  page= "/文件名.jsp"> <jsp:include>,在<body>标签内定义。在编译之前永远是两个java文件。

    静态包含实例代码:先定义一个hel.jsp

    <%--
      Created by IntelliJ IDEA.
      User: sunyubin
      Date: 2018/9/11
      Time: 下午8:25
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Title</title>
    </head>
    <body>
    <%
    String name ="sunyubin";
    %>
    </body>
    </html>
    

      

    再定义一个lo.jsp文件:

    <%--
      Created by IntelliJ IDEA.
      User: sunyubin
      Date: 2018/9/11
      Time: 下午8:27
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ include file="/hel.jsp" %>
    <html>
    <head>
        <title>Title</title>
    </head>
    <body>
    <h1><%=name %><h1/>
    </body>
    </html>
    

     先运行hel.jsp,再运行lo.jsp。

    接下来,再演示一下动态演示过程。

    hel.jsp没有变化;

    变化的只是lo.jsp

    <%--
      Created by IntelliJ IDEA.
      User: sunyubin
      Date: 2018/9/11
      Time: 下午8:27
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    html>
    <head>
        <title>Title</title>
    </head>
    <body>
    <jsp: page include = "/hel.jsp"%>  </jsp:>
    
    <h1><%=name %><h1/>
    
    </body>
    </html>
    

      

  • 相关阅读:
    python的eval、exec函数使用总结
    sorted()&enumerate()
    递归
    作用域
    Python3 os.stat() 方法
    android 电容屏(一):电容屏基本原理篇
    Linux 2.6内核与Linux 3.0 的区别!
    struct device的成员变量bus_id到哪里去了?
    Linux内核中ioremap映射的透彻理解
    Android 通过串口模拟 模拟物理按键
  • 原文地址:https://www.cnblogs.com/sunyubin/p/9630431.html
Copyright © 2020-2023  润新知