当前位置:网站首页>JSP page nesting
JSP page nesting
2022-04-23 02:09:00 【Hua Weiyun】
Some common content can be centralized in a page file , Other pages that use this content only need to contain ( quote ) This general file can . This is easy to maintain , If there are many pages , When the general content needs to be modified , Just change one file , There is no need to modify each file separately .
The most typical applications, such as copyright information in the footer, can be placed in a place called footer.jsp In the document , Then other page files can include this file at the end of the page content .
JSP Files need to be based on Java Running on the server , such as Apache Tomcat.JSP The syntax of the first method of including files is :
<%@ include file="footer.jsp" %>
This instruction indicates : Include pages statically , Whatever the content , Whether static pages or dynamic pages, first add the content of the page .
The second way is to use <jsp:include> Action elements :
<jsp:include page="head.jsp" flush="true" />
When JSP Bring in the specified file when the page is requested .( Execute first , Include after ) This label representation : It can dynamically distinguish whether a dynamic page or a static page is loaded , For static pages, resources are included directly ( Just take its text ).
I know from the above , stay jsp in include There are two forms , Namely
<%@ include file=” ”%><jsp:include page=” ” flush=”true”/>
The former is the instruction element 、 The latter is a behavioral element . Exactly where they will be used ? How to use them and what's the difference between them ? This should be a question that many people will think of when they see it . Let's have a look .
Usually when all the pages in an application are part of ( For example, the title 、 Footer and navigation bar ) When it's all the same , We can consider using include. When to use <%@ include file=” ”%>, When to use <jsp:include page=” ” flush=”true”/>. This form . The first thing to understand is the difference between them . Only by understanding their different usages can we understand when to use them and how to choose .
<%@ include file=” ”%>,jsp Of include The instruction element reads the content of the specified page . And integrate these contents with the original page .( This process is in the translation stage : That is to say jsp Be transformed into servlet The stage of .
Here is a description of the translation stage :jsp The page cannot be sent to the browser intact , be-all jsp All elements must first be processed by the server . This is through jsp The page is transformed into servlet, Then execute this servlet To complete . The server needs a jsp Containers to handle jsp page .jsp Containers are usually in the form of servlet In the form of , This servlet After the configuration , Can deal with jsp All requests for the page .
Jsp The container is responsible for jsp Convert page to servlet( be called jsp Page implementation class JSP Page implementation class), And compile this servlet. These two steps constitute the translation stage .
From this we will know :jsp The page is to put include The actual content of the page specified by the instruction element ( That's code snippets ) Join the jsp On the page , Synthesize a file and get jsp The container turns it into servlet. You can see that a temporary class Documents and a java file .
版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220836091598.html
边栏推荐
- ThinkPHP kernel development blind box mall source code v2 0 docking easy payment / Alibaba cloud SMS / qiniu cloud storage
- Multithreading technology core
- Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy
- 一加一为什么等于二
- What categories do you need to know before using proxy IP?
- 在使用代理IP前需要了解哪些分类?
- Realize linear regression with tensorflow (including problems and solutions in the process)
- 如何选择一台好的拨号服务器?
- 006_ redis_ Jedis quick start
- 007_Redis_Jedis连接池
猜你喜欢

Realize linear regression with tensorflow (including problems and solutions in the process)

一加一为什么等于二

假如404页面是这样的 | 每日趣闻

如何对代理IP进行分类?

What is an API interface?

Shardingsphere read write separation

Is the availability of proxy IP equal to the efficiency of proxy IP?

Campus transfer second-hand market source code

easyswoole环境配置

006_ redis_ Jedis quick start
随机推荐
Summary of I / O knowledge points
PTA: praise the crazy devil
Is CICC fortune a state-owned enterprise and is it safe to open an account
Gray scale range corresponding to colors (red, yellow, green, blue, purple, pink, brick red and magenta) in HSV color space
【Chrome扩展程序】content_script的跨域问题
Dynamic batch processing and static batch processing of unity
002_Redis_String类型常见的操作命令
Tp6 Alibaba cloud SMS window reports curl error 60: SSL certificate problem: unable to get local issuer certificate
App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
easyswoole环境配置
Some tips for using proxy IP.
005_ redis_ Set set
Realize linear regression with tensorflow (including problems and solutions in the process)
011_RedisTemplate操作Hash
Is it better to use a physical machine or a virtual machine to build a website?
[leetcode daily question] 396 Rotation function
Lane cross domain problem
想体验HomeKit智能家居?不如来看看这款智能生态
Leetcode46 Full Permutation
002_ Redis_ Common operation commands of string type