jsp:include page="" 和 include file="" 的区别

下面用三个实验,更清淅的理解 <jsp:include page=""/> 和 <%@ include file="" %> 的区别。
<jsp:include page=""/> 包含被 include 文件的输出
<%@ include file="" %> 包含被 include 文件的代码

a.jsp 内容:

b.jsp 内容:(空)

_a.class a.jsp编译成类的内容:

-------------------------------------------------------------------------------------

a.jsp 内容:

b.jsp 内容:

_a.class a.jsp编译成类的内容

-------------------------------------------------------------------------------------

a.jsp 内容:

b.jsp 内容:

_a.class a.jsp编译成类的内容

以上是在用 WebSphere Application Server 6.1 编译生成的代码反编译出来的 _a.class。

接下来要看看 jsp 指令,如:

<%@page contentType="text/html; charset=UTF-8" %>
<%@page autoFlush="false" %>
<%@page buffer="20kb" %>
<%@page isThreadSafe="true" %>
<%@page errorPage="" %>
<%@page extends="" %>
....................

会体现在生成的 class 文件的何处,分别起什么作用。

本文链接 https://yanbin.blog/jsp-include-page-include-file/, 来自 隔叶黄莺 Yanbin Blog

[版权声明] Creative Commons License 本文采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 进行许可。

Subscribe
Notify of
guest

3 Comments
Inline Feedbacks
View all comments
草儿
16 years ago

说白了 就是<jsp:include page=""/> 运行时插入 <%@ include file="" %> 编译时插入 很简单的问题

Unmi
16 years ago

对的,表达为运行时插入和编译时插入确实好理解些。

class_syh
class_syh
15 years ago

这样很好!有的时候程序用语言是描述不清楚的。