当前位置:网站首页>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
边栏推荐
- 拨号服务器是什么,有什么用处?
- Hyperscan -- 2 compilation
- Dynamic batch processing and static batch processing of unity
- 假如404页面是这样的 | 每日趣闻
- 想体验HomeKit智能家居?不如来看看这款智能生态
- Consider defining a bean of type 'com netflix. discovery. AbstractDiscoveryClientOptionalArgs‘
- [nk]牛客月赛48 D
- EBS:PO_ EMPLOYEE_ HIERARCHIES_ ALL
- Micro build low code zero foundation introductory course
- 009_Redis_RedisTemplate入门
猜你喜欢

Is it better to use a physical machine or a virtual machine to build a website?

简洁开源的一款导航网站源码

PTA: 点赞狂魔

Shardingsphere broadcast table and binding table

006_redis_SortedSet类型

Halo open source project learning (I): project launch

What are the common proxy IP problems?

If 404 page is like this | daily anecdotes

Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储

用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
随机推荐
89 régression logistique prédiction de la réponse de l'utilisateur à l'image de l'utilisateur
PHP sorting of interview questions on April 20, 2022
World Book Day 𞓜 a good book that technicians should not miss (it cutting-edge technology)
Heap overflow of kernel PWN basic tutorial
Network jitter tool clumsy
BGP服务器在什么业务场景会被用到?
Analyze the three functions of static proxy IP.
不断下沉的咖啡业,是虚假的繁荣还是破局的前夜?
How to call out services in idea and display the startup class in services
Find the largest number of two-dimensional arrays
How many steps are there from open source enthusiasts to Apache directors?
A simple and open source navigation website source code
They are all intelligent in the whole house. What's the difference between aqara and homekit?
If 404 page is like this | daily anecdotes
R language advanced | generalized vector and attribute analysis
89 logistic回歸用戶畫像用戶響應度預測
002_Redis_String类型常见的操作命令
What is a dial-up server and what is its use?
Leetcode46 Full Permutation
Introduction to esp32 Bluetooth controller API