当前位置:网站首页>20220209 create a basic Servlet
20220209 create a basic Servlet
2022-07-26 07:28:00 【Zhai [email protected]】
20220209 Create a basic servlet
Create a class or right-click to create servlet
Form a directory as shown in the figure 
Write doGet Method
ServletDemo1.java
package com.helloservlet.hello;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletDemo1 extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println(" receive HTTP Of GET Mode request ");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
super.doPost(req, resp);
}
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
super.service(req, resp);
}
}
To configure xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="WebApp_ID" version="4.0">
<display-name>project20220209</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- To configure servlet -->
<servlet>
<!-- servlet Alias -->
<servlet-name>demo1</servlet-name>
<servlet-class>com.helloservlet.hello.ServletDemo1</servlet-class>
</servlet>
<!-- To configure servlet mapping -->
<servlet-mapping>
<servlet-name>demo1</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
according to xml The document welcome page should be index.html, So there will be index.html The content of , But it's set servlet Intercept , So into servlet Of doGet In the method , It will not be displayed index.html The content of
版权声明
本文为[Zhai [email protected]@]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/201/202207181800523210.html
边栏推荐
- Become an Apache contributor, so easy!
- NFT digital collection development: digital collections help enterprise development
- 深度学习模型部署
- 元宇宙基础设施:WEB 3.0 chain33 优势分析
- NFT数字藏品开发:数字藏品与NFT的六大区别
- HCIP---BGP综合实验
- HOT100 hash
- PXE efficient batch network installation
- Talent column | can't use Apache dolphin scheduler? The most complete introductory tutorial written by the boss in one month [3]
- Comparison and difference between dependence and Association
猜你喜欢

Compose canvas custom circular progress bar

Speech at 2021 global machine learning conference

程序环境和预处理

C# 使用Log4Net记录日志(基础篇)

In July, glassnode data showed that the open position of eth perpetual futures contract on deribit had just reached a one month high of $237959827.

Crawler data analysis

WCF 入门教程二

HCIP---BGP综合实验

Uncover the mystery of cloud native data management: operation level

PR subtitle production
随机推荐
Model pruning 3: learning structured sparsity in deep neural networks
PostgreSQL UUID fuzzy search UUID string type conversion SQL error [42883] explicit type casts
:app:checkDebugAarMetadata 2 issues were found when checking AAR metadata: 2 issues were found when
Unity3d asynchronous loading of scenes and progress bar loading
C# 使用Log4Net记录日志(基础篇)
6、MySQL数据库的备份与恢复
C语言关键字extern
[classic thesis of recommendation system (10)] Alibaba SDM model
“尝鲜”元宇宙,周杰伦最佳拍档方文山将于7月25日官宣《华流元宇宙》
Network Trimming: A Data-Driven Neuron Pruning Approach towards Efficient Deep Architectures论文翻译/笔记
Relevant configurations of pychart: change font style and size, change picture background, and change the font color of console output
tensorflow2.x中的量化感知训练以及tflite的x86端测评
元宇宙基础设施:WEB 3.0 chain33 优势分析
6. Combined data type
NFT数字藏品开发:数字藏品与NFT的六大区别
PostgreSQL sequence create alter nextval Curval numerical interval gap
Oauth2.0 series blog tutorial summary
Data platform scheduling upgrade and transformation | operation practice from Azkaban smooth transition to Apache dolphin scheduler
从Boosting谈到LamdaMART
[keras entry log (3)] sequential model and functional model in keras