当前位置:网站首页>2021.8.7 note Servlet
2021.8.7 note Servlet
2022-07-27 18:33:00 【It's food, not shellfish】
servlet
summary



I've been doing it for a long time 404... The solution is deployment Inside application context Change to /
servlet Execution principle


Life cycle approach





Annotation configuration
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
@WebServlet("/demo3")
public class ServletPratice implements Servlet {
@Override
public void init(ServletConfig servletConfig) throws ServletException {
}
@Override
public ServletConfig getServletConfig() {
return null;
}
@Override
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
System.out.println("servlet4.0...");
}
@Override
public String getServletInfo() {
return null;
}
@Override
public void destroy() {
}
}
there value No , because value Refers to the most important , Obviously, the most important thing here is urlpattern, only one value You can put "value" delete .
idea And tomcat Related configuration

HttpServlet
It mainly involves forms get and post
Can be rewritten doget and dopost Method
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/demo4")
public class DemoClass extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("doget...");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("dopost...");
}
}
Always forgetting to add virtual directories leads to 404..
Set a mark : genericServlet

urlpattern To configure
//@WebServlet({"/de1","/de2","/de3"})
//@WebServlet({"/user/gogo) Two level directory
//@WebServlet({"/*"}) Display everything you enter , But the priority is the lowest
//@WebServlet({"*.do"}) No matter which one you want to add .do, Cannot add /
边栏推荐
- [MIT 6.S081] Lab 7: Multithreading
- 2021.7.13笔记 子查询
- 深度学习-视频行为识别:论文阅读——双流网络(Two-stream convolutional networks for action recognition in videos)
- 深度学习:GCN案例
- Deep learning - paper reading: action structural graph convolution network as-gcn
- uniapp H5跨域问题
- LootCode动态数组练习(724,118,766)
- [MIT 6.S081] Lec 5: Calling conventions and stack frames RISC-V 笔记
- Linked list storage structure of dynamic linked list 2 stack (linkedstack Implementation)
- Deep learning: Gan case exercise -minst handwritten digits
猜你喜欢

Installation and deployment of zabbix6.0

3. opencv几何变换

二叉树概念
![[MIT 6.S081] Lec 1: Introduction and examples 笔记](/img/5d/2fc4bde8eebbb22605d314b5292e05.png)
[MIT 6.S081] Lec 1: Introduction and examples 笔记

2021.7.12笔记 内外连接

Let's move forward together, the 10th anniversary of Google play!
![[MIT 6.S081] Lec 8: Page faults 笔记](/img/e2/0f5332dd9d2b439bcf29e87a9fa27f.png)
[MIT 6.S081] Lec 8: Page faults 笔记

Deep recognition: thesis reading_ 2s-agcn cvpr2019 (two stream adaptive graph convolution network based on skeleton action recognition)

深度学习:GCN(图卷积神经网络)理论学习总结
![[mit 6.s081] LEC 6: isolation & system call entry/exit notes](/img/b3/89b3688a06aa39d894376d57acb2af.png)
[mit 6.s081] LEC 6: isolation & system call entry/exit notes
随机推荐
[MIT 6.S081] Lec 3: OS organization and system calls 笔记
[MIT 6.S081] Lec 1: Introduction and examples 笔记
Collection! 0 basic open source data visualization platform flyfish large screen development guide
文件路径读取
2021.7.13 note sub query
MySQL学习 Day2 排序查询 / 聚合函数 /分组查询 /分页查询 /约束/多表之间的关系
动态链表3队列的链式存储结构(LinkedQueue实现)
C杂讲 链表初讲
Nowcoder (5 choices)
[mit 6.s081] LEC 1: introduction and examples notes
Is it difficult to operate email safely? COREMAIL joins hands with cloud store to create a new ecosystem of corporate email office!
Deep recognition: thesis reading_ 2s-agcn cvpr2019 (two stream adaptive graph convolution network based on skeleton action recognition)
Deep learning: gat
2021.7.31笔记 视图
Linked list storage structure of dynamic linked list 2 stack (linkedstack Implementation)
[MIT 6.S081] Lab 11: networking
2021.7.22笔记 约束
动态链表4单向循环链表(LoopSingle实现)
Hackers use lasers to attack, and voice assistants can be activated from a distance of 100 meters
2021.7.13笔记 子查询