当前位置:网站首页>Summary of request and response and their ServletContext
Summary of request and response and their ServletContext
2022-04-23 13:11:00 【ArchieSean】
The blogger's name is taken from 《 Shaun the Sheep 》 Shawn the lamb in the , The name is : Sean , Transliterated as Sean, Take your own last name : Archie , In order to conform to our reading habits , Connected to form ArchieSean. The blogger is currently a junior reading , Aiming to build blog into a technical stack of personal online notes , Be convenient for yourself and others . If there are any mistakes in the blog , Please point out , Thank you. .
List of articles
Request and Response
principle
- request and response Are objects provided by the server .
- request Is used to get the request message
- response Is used to set the response message .
Request
Request Architecture of
Another class is provided by the server , It has achieved HttpServletRequest Interface .
Request The function of
More commonly used are :
- A common way to get request parameters
request.getParameter(String name);
request. getParameterValues(String name);
request.getParameterNames();
request. getParameterMap();
- solve POST Ask for Chinese code
request.setCharacterEncoding("utf-8");
- forward
request.getRequestDispatcher(String path).forward(request,response);
- Use of shared data
request.setAttribute(String key,Object obj);
request.getAttribute(String key);
request.removeAttribute(String key);
- obtain ServletContext object
request.getServletContext();
Response
Response Architecture
Same as Request equally , Provides a server class , Realized HttpServletResponse Interface .
Response The function of
Commonly used :
- Solve the problem of Chinese garbled code
resp.setContentType("MIME type ; Character set ");
- Get stream object
- Get character output stream
- Get byte output stream
- Redirect
resp.sendRedirect(String path);
ServletContext
summary
Simply speaking ,ServletContext yes web The largest domain object in the application . It means that all users under the same server can share data .
obtain
There are two ways to get this object :
- adopt request To get
request.getServletContext();
- adopt servlet To get
this.getServletContext();
function
- Data sharing ( Three general methods of domain objects )
- obtain MIME type
getMimeType(String file);
- Get resource path
getRealPath(String path);
If there are any questions in the blog , Please leave a message .
版权声明
本文为[ArchieSean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231306322713.html
边栏推荐
- How to convert opencv pictures to bytes
- 鸿蒙系统是抄袭?还是未来?3分钟听完就懂的专业讲解
- nodeJs + websocket 循环小案例
- STD:: shared of smart pointer_ ptr、std::unique_ ptr
- 十万大学生都已成为猿粉,你还在等什么?
- 2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)
- ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
- Byte warehouse intern interview SQL questions
- Design of body fat detection system based on 51 single chip microcomputer (51 + OLED + hx711 + US100)
- pyqt5 将opencv图片存入内置SQLlite数据库,并查询
猜你喜欢
叮~ 你的奖学金已到账!C认证企业奖学金名单出炉
Kernel error: no rule to make target 'Debian / canonical certs pem‘, needed by ‘certs/x509_ certificate_ list‘
CMSIS cm3 source code annotation
Important knowledge of network layer (interview, reexamination, term end)
100 GIS practical application cases (51) - a method for calculating the hourly spatial average of NC files according to the specified range in ArcGIS
jmeter操作redis
mui + hbuilder + h5api模拟弹出支付样式
【快排】215. 数组中的第K个最大元素
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
web三大组件之Servlet
随机推荐
普通大学生如何拿到大厂offer?敖丙教你一招致胜!
FatFs FAT32 learning notes
The use of dcast and melt in R language is simple and easy to understand
Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
Imx6ull QEMU bare metal tutorial 1: GPIO, iomux, I2C
Async void caused the program to crash
CSDN高校俱乐部“名师高校行”——湖南师范大学站
[walking notes]
STM32 tracking based on open MV
MySQL5.5安装教程
Armv8m (cortex M33) MPU actual combat
Ffmpeg common commands
Esp32 vhci architecture sets scan mode for traditional Bluetooth, so that the device can be searched
Uniapp image import local image not displayed
缘结西安 | CSDN与西安思源学院签约,全面开启IT人才培养新篇章
AUTOSAR from introduction to mastery 100 lectures (51) - AUTOSAR network management
100 lectures on practical application cases of Excel (VIII) - report connection function of Excel
Go iris framework implements multi service Demo: start (listen to port 8084) service 2 through the interface in service 1 (listen to port 8083)
Go language array operation
Golang realizes regular matching: the password contains at least one digit, letter and special character, and the length is 8-16