JavaWeb知识小汇(4)—— jsp指令

jsp指令
<%@ page ... %><!--page指令-->

<%@include file=""%><!--include指令-->

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><!--taglib指令-->

include两种方法的区别:

<body>
<%--include指令  将两个页面合二为一--%>
<%@include file="common/header.jsp"%>
<h1>页面中间</h1>
<%@include file="common/footer.jsp"%>
<hr>
<%--jsp标签库  本质还是三个--%>
<jsp:include page="/common/header.jsp"></jsp:include>
<h1>页面中间</h1>
<jsp:include page="/common/footer.jsp"></jsp:include>
</body>

源码分析:_jspService中的代码

out.write("\r\n");
      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("    <title>Title</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write('\r');
      out.write('\n');
      out.write("\r\n");
      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("    <title>header</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
//include指令方法
      /*out.write("<h1>我是header</h1>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
      out.write("\r\n");
      out.write("<h1>页面中间</h1>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("    <title>footer</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write("<h1>我是footer</h1>\r\n");*/
      out.write("</body>\r\n");
      out.write("</html>\r\n");
      out.write("\r\n");
      out.write("<hr>\r\n");
      out.write('\r');
      out.write('\n');
//jsp标签库方法   通过引用,引用的对象如下静态代码块
      /*org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "common/header.jsp", out, false);
      out.write("\r\n");
      out.write("<h1>页面中间</h1>\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "common/footer.jsp", out, false);*/
      out.write("\r\n");
      out.write("\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");

jsp标签库方法引用的静态代码块,此静态代码块再类中,并没有在_jspService方法中

static {
    _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(2);
    _jspx_dependants.put("/common/header.jsp", Long.valueOf(1611294179577L));
    _jspx_dependants.put("/common/footer.jsp", Long.valueOf(1611294179662L));
  }

九大内置对象

pageContext  存数据
request 存数据
response
session 存数据
out
page
config [servletConfig]
application [servletContext] 存数据
excepition

如有不对的地方欢迎指出,大家共同进步!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值