当前位置:网站首页>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
边栏推荐
- Install nngraph
- The first lesson is canvas, showing a small case
- Wu Enda's programming assignment - logistic regression with a neural network mindset
- Nodejs + websocket cycle small case
- 9419页最新一线互联网Android面试题解析大全
- 榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
- 8086 of x86 architecture
- CMSIS cm3 source code annotation
- LeetCode_DFS_中等_695.岛屿的最大面积
- melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
猜你喜欢
Complete project data of UAV apriltag dynamic tracking landing based on openmv (LabVIEW + openmv + apriltag + punctual atom four axes)
vscode小技巧
“湘见”技术沙龙 | 程序员&CSDN的进阶之路
100 GIS practical application cases (52) - how to keep the number of rows and columns consistent and aligned when cutting grids with grids in ArcGIS?
在 pytorch 中加载和使用图像分类数据集 Fashion-MNIST
Learning notes of AMBA protocol
【官宣】长沙软件人才实训基地成立!
MySQL -- 16. Data structure of index
Common interview questions and detailed analysis of the latest Android developers in 2020
Summary of JVM knowledge points - continuously updated
随机推荐
Recovering data with MySQL binlog
2021年6月程序员工资统计,平均15052元,你拖后腿了吗?
MySQL -- 16. Data structure of index
解决虚拟机中Oracle每次要设置ip的问题
Design and manufacture of 51 single chip microcomputer solar charging treasure with low voltage alarm (complete code data)
100 GIS practical application cases (34) - splicing 2020globeland30
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
[notes de marche]
Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
5道刁钻的Activity生命周期面试题,学完去吊打面试官!
Brief introduction of asynchronous encapsulation interface request based on uniapp
Imx6ull QEMU bare metal tutorial 2: usdhc SD card
Golang implements MD5, sha256 and bcrypt encryption
(个人)最近项目开发后存在的系统漏洞整理
Introduction to metalama 4 Use fabric to manipulate items or namespaces
100 lectures on practical application cases of Excel (VIII) - report connection function of Excel
Request和Response及其ServletContext总结
MySQL —— 16、索引的数据结构
mysql 基本语句查询
Byte warehouse intern interview SQL questions