当前位置:网站首页>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 /
边栏推荐
- 文件路径读取
- uniapp H5跨域问题
- XML学习 Day1 : xml / Jsoup解析器 / selector选择器 /Xpath选择器
- Deep learning: a survey of behavior recognition
- Linked list storage structure of dynamic linked list 2 stack (linkedstack Implementation)
- 力压谷歌、英伟达!阿里含光800芯片再获权威测试世界第一
- 深度学习:GCN(图卷积神经网络)理论学习总结
- OEM "made in the United States", domestic security equipment has been installed on the U.S. aircraft carrier!
- 2021.8.6笔记 jsoup
- Lotcode dynamic array exercise (724118766)
猜你喜欢

View port PID and end process

Deep learning: stgcn learning notes

微信小程序获取openId, sessionKey, unionId

Publish your own NPM component library

Meituan Er Mian: why does redis have sentinels?

2021.7.31笔记 视图

深度学习:GCN图分类案例
![[MIT 6.S081] Lec 10: Multiprocessors and locking 笔记](/img/62/ca6362830321feaf450865132cdea9.png)
[MIT 6.S081] Lec 10: Multiprocessors and locking 笔记

Deep learning: GCN (graph convolution neural network) theory learning summary
![[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
随机推荐
深度学习:GCN(图卷积神经网络)理论学习总结
OEM "made in the United States", domestic security equipment has been installed on the U.S. aircraft carrier!
[MIT 6.S081] Lab 11: networking
MySQL学习 Day3 多表查询 / 事务 / DCL
1. OpenCV image basic operation
请教大神一个问题 flinkcdc,同步mysql中的datetime字段会变为时间戳 有人遇到过吗
携手三星,vivo将推Exynos980双模5G手机!
动态链表2栈的链表存储结构(LinkedStack实现)
贴牌“美国制造”,国产安防设备竟被装上了美航母!
rsa加解密(兼容微信小程序环境)
RSA encryption and decryption (compatible with wechat applet environment)
Deep recognition: thesis reading_ 2s-agcn cvpr2019 (two stream adaptive graph convolution network based on skeleton action recognition)
3. opencv几何变换
C杂讲 链表初讲
二叉树概念
[MIT 6.S081] Lab 6: Copy-on-Write Fork for xv6
超实用!阿里P9私藏的Kubernetes学习笔记,看完直呼NB
[MIT 6.S081] Lab 10: mmap
深度学习:安装包记录
Is it difficult to operate email safely? COREMAIL joins hands with cloud store to create a new ecosystem of corporate email office!