当前位置:网站首页>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
边栏推荐
- 5道刁钻的Activity生命周期面试题,学完去吊打面试官!
- MySQL -- 16. Data structure of index
- SPI NAND flash summary
- Community version Alibaba MQ ordinary message sending subscription demo
- Golang realizes regular matching: the password contains at least one digit, letter and special character, and the length is 8-16
- The filter() traverses the array, which is extremely friendly
- Common interview questions and detailed analysis of the latest Android developers in 2020
- 【行走的笔记】
- Conflict between Mui picker and drop-down refresh
- Custom nail robot alarm
猜你喜欢
8086 of x86 architecture
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
9419 page analysis of the latest first-line Internet Android interview questions
[51 single chip microcomputer traffic light simulation]
Hbuilderx + uniapp packaging IPA submission app store stepping on the pit
榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
CSDN高校俱乐部“名师高校行”——湖南师范大学站
mui + hbuilder + h5api模拟弹出支付样式
2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)
@优秀的你!CSDN高校俱乐部主席招募!
随机推荐
鸿蒙系统是抄袭?还是未来?3分钟听完就懂的专业讲解
Nodejs + websocket cycle small case
Learning notes of AMBA protocol
LeetCode_DFS_中等_695.岛屿的最大面积
【动态规划】221. 最大正方形
这几种 VSCode 扩展是我最喜欢的
filter()遍历Array异常友好
Melt reshape decast long data short data length conversion data cleaning row column conversion
Uniapp image import local image not displayed
5 tricky activity life cycle interview questions. After learning, go and hang the interviewer!
The project file '' has been renamed or is no longer in the solution, and the source control provider associated with the solution could not be found - two engineering problems
8086 of x86 architecture
榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
These vscode extensions are my favorite
MySQL -- 16. Data structure of index
Esp32 vhci architecture sets scan mode for traditional Bluetooth, so that the device can be searched
jmeter操作redis
Recovering data with MySQL binlog
Customize classloader and implement hot deployment - use loadclass
Utils of various date conversion