当前位置:网站首页>Knowledge summary of request
Knowledge summary of request
2022-07-06 12:12:00 【Lingxiaoyuan】
Request:
1. request Objects and response The principle of objects
1. request and response Objects are created by the server . Let's use them
2. request Object to get the request message ,response Object to set the response message
2. request Object inheritance Architecture :
ServletRequest -- Interface
| Inherit
HttpServletRequest -- Interface
| Realization
org.apache.catalina.connector.RequestFacade class (tomcat)
3. request function :
1. Get request message data
1. Get request line data
* GET /day14/demo1?name=zhangsan HTTP/1.1
* Method :
1. Get request method :GET
* String getMethod()
2. (*) Get virtual directory :/day14
* String getContextPath()
3. obtain Servlet route : /demo1
* String getServletPath()
4. obtain get Mode request parameters :name=zhangsan
* String getQueryString()
5. (*) Get request URI:/day14/demo1
* String getRequestURI(): /day14/demo1
* StringBuffer getRequestURL() :http://localhost/day14/demo1
* URL: Uniform resource locator : http://localhost/day14/demo1 The People's Republic of China
* URI: Uniform resource identifiers : /day14/demo1 republic
6. Get the protocol and version :HTTP/1.1
* String getProtocol()
7. Get the... Of the client IP Address :
* String getRemoteAddr()
2. Get request header data
* Method :
* (*)String getHeader(String name): Get the value of the request header by the name of the request header
* Enumeration<String> getHeaderNames(): Get all request header names
3. Get request body data :
* Request body : Only POST Request mode , There's a requester , Encapsulate... In the request body POST Requested request parameters
* step :
1. Get stream object
* BufferedReader getReader(): Get character input stream , Only character data can be operated
* ServletInputStream getInputStream(): Get byte input stream , All types of data can be manipulated
* Explain after uploading the knowledge points of the file
2. Then take the data from the flow object
2. Other features :
1. Get request parameters in general : Regardless of get still post The following methods can be used to obtain request parameters in both request methods
1. String getParameter(String name): Get the parameter value according to the parameter name username=zs&password=123
2. String[] getParameterValues(String name): Get the array of parameter values according to the parameter name hobby=xx&hobby=game
3. Enumeration<String> getParameterNames(): Get all requested parameter names
4. Map<String,String[]> getParameterMap(): Get... For all parameters map aggregate
* Chinese code scrambling :
* get The way :tomcat 8 Have already put get The problem of disorderly pattern has been solved
* post The way : It's messy
* solve : Before getting the parameters , Set up request The coding request.setCharacterEncoding("utf-8");
This request.setCharacterEncoding("utf-8"); that will do
2. Request forwarding : A way to jump resources inside the server
1. step :
1. adopt request Object get request forwarder object :RequestDispatcher getRequestDispatcher(String path)
2. Use RequestDispatcher Object to forward :forward(ServletRequest request, ServletResponse response)
2. characteristic :
1. The browser address bar path does not change
2. It can only be forwarded to the internal resources of the current server .
3. Forwarding is a request
3. Shared data :
* Domain object : An object of scope , Data can be shared in scope
* request Domain : Represents the scope of a request , It is generally used to share data among multiple resources for request forwarding
* Method :
1. void setAttribute(String name,Object obj): Store the data
2. Object getAttitude(String name): Get value by key
3. void remove (String name): Remove key value pairs by key
边栏推荐
- Understanding of AMBA, AHB, APB and Axi
- C语言,log打印文件名、函数名、行号、日期时间
- Imgcat usage experience
- AMBA、AHB、APB、AXI的理解
- Important methods of array and string
- Arduino uno R3 register writing method (1) -- pin level state change
- 共用体(union)详解【C语言】
- ARM PC=PC+8 最便于理解的阐述
- Esp8266 uses Arduino to connect Alibaba cloud Internet of things
- Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
猜你喜欢

Cannot change version of project facet Dynamic Web Module to 2.3.

Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries(XGBoost)

JS变量类型以及常用类型转换

Machine learning -- decision tree (sklearn)

IOT system framework learning

物联网系统框架学习

Esp8266 uses Arduino to connect Alibaba cloud Internet of things
![[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree](/img/6e/0802a92511ac50a652afa1678ad28c.jpg)
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree

Kconfig Kbuild

电商数据分析--薪资预测(线性回归)
随机推荐
The dolphin scheduler remotely executes shell scripts through the expect command
Keyword inline (inline function) usage analysis [C language]
共用体(union)详解【C语言】
【ESP32学习-1】Arduino ESP32开发环境搭建
STM32 how to locate the code segment that causes hard fault
OPPO VOOC快充电路和协议
C语言回调函数【C语言】
map文件粗略分析
FreeRTOS 任务函数里面的死循环
电商数据分析--用户行为分析
RT-Thread API参考手册
E-commerce data analysis -- User Behavior Analysis
列表的使用
Pytoch temperature prediction
Embedded startup process
. elf . map . list . Hex file
Several declarations about pointers [C language]
Reno7 60W超级闪充充电架构
GNN的第一个简单案例:Cora分类
JS變量類型以及常用類型轉換