当前位置:网站首页>Servlet of three web components
Servlet of three web components
2022-04-23 13:11:00 【ArchieSean】
The blogger's name is taken from 《 Shaun the Sheep 》 Shawn the lamb in the , The name is : Sean , Transliterated as Sean, Take your own last name : Archie , In order to conform to our reading habits , Connected to form ArchieSean. The blogger is currently a junior reading , Aiming to build blog into a technical stack of personal online notes , Be convenient for yourself and others . If there are any mistakes in the blog , Please point out , Thank you. .
List of articles
servlet summary
Simply speaking , It is a server-side applet .
servlet It's an interface , It defines the java Class is accessed by the browser .
servlet Structure system
servlet Method
Pictured Realization servlet Interface , Rewrite its method .
import javax.servlet.*;
import java.io.IOException;
public class Csdn implements Servlet {
@Override
// Initialization method , stay servlet Execute when created , And only once
public void init(ServletConfig servletConfig) throws ServletException {
}
@Override
// obtain ServletConfig object
public ServletConfig getServletConfig() {
return null;
}
@Override
// How to provide services , Execute on each visit
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
}
@Override
// return servlet Information about , For example, the author , Version, etc
public String getServletInfo() {
return null;
}
@Override
// Destruction method , Called when the server shuts down
public void destroy() {
}
}
servlet Life cycle
- born : init Method execution , And only once ,servlet Be created .
By default , On first visit ,servlet Be created , It can also be created when the server starts . - Alive : perform service Method , Multiple executions .
- Death : destroy Method execution
When the server is down , perform destriy Method ,servlet Be destroyed .
servlet Of xml To configure
be located WEB-INF Under the web.xml
<web-app>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>com.xxx.servlet.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
servlet principle
As shown in the figure above :
- When the server receives a server request , Can parse url route , Get access to servlet The resource path of .
- The server will look for web.xml file , Find the one consistent with the access path url-pattern Label content
- Then find the corresponding servlet-class label , Get servlet Full class name of
- Put this kind of class File loaded into memory ( Using reflection :Class.forName() To load the )
- Create its object ( Reflection :Class.newInstance() Create objects )
- call service Method
Servlet The annotation configuration of
@webServlet(value=" Access path ")
Add this annotation to servlet Class , There is no need for xml The configuration of the .
request and response I'll summarize in the next article . If there are any questions in the blog , Please leave a comment in the comment area , thank you .
版权声明
本文为[ArchieSean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231306322754.html
边栏推荐
- 【行走的笔记】
- Design of STM32 multi-channel temperature measurement wireless transmission alarm system (industrial timing temperature measurement / engine room temperature timing detection, etc.)
- AUTOSAR from introduction to mastery 100 lectures (50) - AUTOSAR memory management series - ECU abstraction layer and MCAL layer
- 在 pytorch 中加载和使用图像分类数据集 Fashion-MNIST
- 51 single chip microcomputer stepping motor control system based on LabVIEW upper computer (upper computer code + lower computer source code + ad schematic + 51 complete development environment)
- These vscode extensions are my favorite
- Scons build embedded ARM compiler
- PC starts multiple wechat at one time
- [untitled] make a 0-99 counter, P1 7 connected to key, P2 connected to nixie tube section, common anode nixie tube, P3 0,P3. 1. Connect the nixie tube bit code. Each time you press the key, the nixie
- EMMC / SD learning notes
猜你喜欢
Learning materials
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
hbuilderx + uniapp 打包ipa提交App store踩坑记
Recovering data with MySQL binlog
The use of dcast and melt in R language is simple and easy to understand
100 GIS practical application cases (52) - how to keep the number of rows and columns consistent and aligned when cutting grids with grids in ArcGIS?
【动态规划】221. 最大正方形
Data warehouse - what is OLAP
three.js文字模糊问题
数据仓库—什么是OLAP
随机推荐
Go language: passing slices between functions
Go language mapping operation
The filter() traverses the array, which is extremely friendly
PC starts multiple wechat at one time
(1) Openjuterpyrab comparison scheme
Common interview questions and detailed analysis of the latest Android developers in 2020
【行走的笔记】
Ffmpeg common commands
Kernel error: no rule to make target 'Debian / canonical certs pem‘, needed by ‘certs/x509_ certificate_ list‘
Community version Alibaba MQ ordinary message sending subscription demo
Learning materials
4.22学习记录(你一天只做了水题是吗)
Nodejs + Mysql realize simple registration function (small demo)
async void 導致程序崩潰
CMSIS cm3 source code annotation
Important knowledge of transport layer (interview, retest, final)
Mui wechat payment pit
CSDN高校俱乐部“名师高校行”——湖南师范大学站
MySQL —— 16、索引的数据结构
Hanlp word splitter (via spark)