当前位置:网站首页>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
边栏推荐
- 4. Data integrity
- Keras learning part: obtaining the output results of neural network middle layer
- This section is for Supplement 2
- Machine learning related competition website
- 依赖和关联的对比和区别
- 时间序列分析预测实战之ARIMA模型
- 元宇宙基础设施:WEB 3.0 chain33 优势分析
- NFT digital collection system development: the collision of literature + Digital Collections
- Learn browser decoding from XSS payload
- Typora免费版下载安装
猜你喜欢

Learning Efficient Convolutional Networks Through Network Slimming

Hcip--- MPLS detailed explanation and BGP route filtering

单身杯web wp

如何保证缓存和数据库的双写一致性?

深度学习模型部署

Compose Canvas line chart

HCIP---BGP综合实验

Pycharm common shortcut keys

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.

Taishan office lecture: word error about inconsistent values of page margins
随机推荐
什么是消息订阅和发布?
VScode无法启动问题解决思路
HCIP---BGP综合实验
Anaconda installation tutorial - hands on installation
Configure flask
NFT digital collection system development: what are the best digital marketing strategies for NFT digital collection
NFT digital collection development: digital collections help enterprise development
NFT digital collection system development: the collision of literature + Digital Collections
MMOE多目标建模
QT: modal, modeless, text box, button, single line input box
C51 and MDK coexist keil5 installation tutorial
【每日一题】919. 完全二叉树插入器
MySQL syntax (2) (pure syntax)
【推荐系统经典论文(十)】阿里SDM模型
又是一年开源之夏,1.2万项目奖金等你来拿!
NFT digital collection development: digital art collection enabling public welfare platform
3.0.0 alpha blockbuster release! Nine new functions and new UI unlock new capabilities of dispatching system
NFT digital collection system development: digital collections give new vitality to brands
[keras entry log (3)] sequential model and functional model in keras
mysql语法(二)(纯语法)