zoukankan      html  css  js  c++  java
  • 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>
    

      

  • 相关阅读:
    输入一批整数,输出最大最小值,输入0结束
    获取最低价手机价格
    插入数值
    猜数游戏
    数字金字塔
    输出星期数
    9*9乘法表
    linux 出core设置问题
    linux socket连接中 ERRNO错误
    linux c 获取头文件函数getenv
  • 原文地址:https://www.cnblogs.com/sunyubin/p/9630431.html
Copyright © 2011-2022 走看看