jsp指令_JSP包含指令

jsp指令

The include directive tells the Web Container to copy everything in the included file and paste it into current JSP file. Syntax of include directive is:

include指令告诉Web容器复制包含文件中的所有内容并将其粘贴到当前JSP文件中。 include指令的语法为:

<%@ include file="filename.jsp" %>
Jsp Include Directive

包含指令的示例 (Example of include directive)

welcome.jsp

welcome.jsp

<html>
    <head>
        <title>Welcome Page</title>
    </head>
   
  <body>
        Welcome, User
  </body>
</html>

header.jsp

header.jsp

<html>
  <body>
      <img src="header.jpg" alt="This is Header image" / >  
  </body>
</html>

The example above is showcasing a very standard practice. Whenever we are building a web application, with webpages, all of which have the top navbar and bottom footer same. We make them as separate jsp files and include them using the include directive in all the pages. Hence whenever we have to update something in the top navbar or footer, we just have to do it at one place. Handy, isn't it?

上面的示例展示了非常标准的做法。 每当我们构建带有网页的Web应用程序时,它们的顶部导航栏和底部页脚都相同。 我们将它们制作为单独的jsp文件,并在所有页面中使用include指令将它们include 。 因此,每当我们必须更新顶部导航栏或页脚中的某些内容时,我们只需要在一个地方进行即可。 方便,不是吗?

include directive example real world

One more standard application of include directive is, if you create a separate jsp file, with some commonly used functions, kind of like a util jsp file. Which can be included in the web pages wherever you want to use those functions.

include指令的另一个标准应用程序是,如果您创建一个单独的具有某些常用功能的jsp文件,则类似于util jsp文件。 无论您想在何处使用这些功能,都可以将其包含在网页中。

include directive example real world

Similarly, there are many ways in which this directive proves to be quite useful in giving a structure to your web application code.

同样,在很多情况下,此伪指令在为Web应用程序代码提供结构时也非常有用。

翻译自: https://www.studytonight.com/jsp/jsp-include-directive.php

jsp指令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值