当前位置:网站首页>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
边栏推荐
- 漂洋过海来看你
- NFT digital collection system development: how enterprises develop their own digital collection platform
- Moonbeam orbiters program: provides a new way for collectors to participate in moonbeam and Moonriver
- :app:checkDebugAarMetadata 2 issues were found when checking AAR metadata: 2 issues were found when
- 5. Multi table query
- 6. Backup and recovery of MySQL database
- ARIMA model for time series analysis and prediction
- Singles cup web WP
- 单身杯web wp
- NFT digital collection development: digital art collection enabling public welfare platform
猜你喜欢
![Leetcode:749. isolate virus [Unicom component + priority queue + status representation]](/img/61/00f2a1aa30d2c5f5e5d96e773a8f30.png)
Leetcode:749. isolate virus [Unicom component + priority queue + status representation]

博途PLC一阶滞后系统传递函数阶跃响应输出仿真(SCL)

“尝鲜”元宇宙,周杰伦最佳拍档方文山将于7月25日官宣《华流元宇宙》

NFT digital collection system development: what are the best digital marketing strategies for NFT digital collection

DevExpress.XtraEditors.DataNavigator用法

【每日一题】919. 完全二叉树插入器

在线问题反馈模块实战(十四):实现在线答疑功能

PG operation and maintenance -- logical backup and physical backup practice

机器学习相关比赛网站
![[C language] do you really know printf? (printf is typically error prone, and collection is strongly recommended)](/img/59/cf43b7dd16c203b4f31c1591615955.jpg)
[C language] do you really know printf? (printf is typically error prone, and collection is strongly recommended)
随机推荐
DevExpress.XtraEditors.DataNavigator用法
PostgreSQL UUID fuzzy search UUID string type conversion SQL error [42883] explicit type casts
MMOE多目标建模
机器学习相关比赛网站
漂洋过海来看你
Learning Efficient Convolutional Networks Through Network Slimming
Open source management system based on ThinkPHP
NFT数字藏品开发:数字藏品助力企业发展
IDEA快捷键
NFT digital collection development: digital art collection enabling public welfare platform
Leetcode:749. isolate virus [Unicom component + priority queue + status representation]
NLP natural language processing - Introduction to machine learning and natural language processing (3)
C# 使用Log4Net记录日志(基础篇)
NFT digital collection system development: digital collections give new vitality to brands
「论文笔记」Next-item Recommendations in Short Sessions
NFT数字藏品系统开发:华为发布首款珍藏版数字藏品
Speech at 2021 global machine learning conference
Model pruning 3: learning structured sparsity in deep neural networks
Singles cup web WP
pycharm常用快捷键