开发者社区> 问答> 正文

jsp中include指令的作用是什么?

jsp中include指令的作用是什么?

展开
收起
游客k7rjnht6hbtk6 2021-10-27 23:19:08 2469 0
1 条回答
写回答
取消 提交回答
  • jsp中include指令的作用:1,jsp向当前页面加入另一文件的方法:<jsp:include page=”relativefileURL” flush=”true”/> 2,是用来向当前页中插入一个静态文件的内容,这个文件可能是html文件、jsp文件或其它文本文件,格式如下:<%@ include file=”include.inc”%>如:native.jsp:native file start here.
    <%@ include file=”include.inc”%>native file end here.
    include.inc:include file start here.
    <%! String str=”Here is include’s context!”;%><% out.pringln(str+”
    ”);%>include file end here.
    运行native.jsp,结果如下:native file start here.include file start here.Here is include’s context!include file end here.native file end here.注意:因为include.inc文件是在编译时才插入的,所以只改 include.inc文件内容,而不对原JSP页面做修改,得到的结果仍将是以前的结果。(因为一开始JSP引擎就判断了JSP页面没被改动过,就直接执行已存在的字节码,而不对源代码重新编译,这样对include做的修改也就在这没有反映。)

    2021-10-27 23:19:30
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载