introduce
HttpServletRequest defines a series of methods to obtain the request line, request header and request body, and can store information as a domain
common method
Request line
String getRemoteAddr()
Parameter: None
Return value: String
Meaning of return value: obtain the client IP address
Function: obtain the client IP address
Request header
String getHead(String name)
Parameters:
String Name: the name of the request header
Return value: String
Meaning of return value: get the value corresponding to the request header
Function: get the value corresponding to the request body
Enumeration getHeaderNames()
Parameter: None
Return value: enumeration < String>
Return value meaning: get the enumeration of all request header names
Function: get the enumeration of all request header names
Request body
String getParameter(String name)
Parameters:
String Name: the name of the request body parameter
Return value: String
Meaning of return value: get the value corresponding to the request body parameter name
Function: get the value corresponding to the request body parameter name
Enumeration< String> getParameterNames()
Parameter: None
Return value: enumeration & lt; String>
Meaning of return value: get the enumeration of all request headers
Function: get the enumeration of all request headers
Request field
void setAttribute(String name ,Object obj)
Parameters:
String Name: the name of the information in the field
Object obj: field value
Return value: None
Return value meaning: None
Scope: store information in the request domain for forwarding
Object geAttribute(String name)
Parameters:
String Name: the name of the information in the field
Return value: object
Meaning of return value: get the object corresponding to the information name in the field
Scope: get the object corresponding to the information name in the domain
Other
void setCharacterEncoding(String name)
Parameters:
String Name: character set
Return value: None
Return value meaning: None
Function: set the character set in the request body
Similar Posts:
- [Solved] HttpClient HttpRequestHeaders.From Error: The specified value is not a valid ‘From’ header string.
- Spring Cloud Openfeign Get Request 405 Error [How to Solve]
- The solution of ‘STR’ object has no attribute ‘get’ error
- Servlet jump mode sendredirect() and forward ()
- [Swift] an error occurs when passing parameters using alamofire
- C++ error: cannot bind non-const lvalue reference of type ‘myString&’ to an rvalue of type ‘m…
- Error during WebSocket handshake 403 [How to Solve]
- [Solved] Java Call Error: java.lang.IllegalArgumentException: wrong number of arguments
- Solution to the problem of missing URI path in chrome 85 + referer
- invalid conversion from ‘void* (*)()’ to ‘void* (*)(void*)’