Request method
Common methods in doget/post
Garbled problem
effect | Code |
---|---|
Prevent garbled pages | setContentType(“text/html;charset=utf-8”); |
Prevent garbled code when getting post | setCharacterEncoding(“utf-8”); |
basic function
effect | Code |
---|---|
Get virtual path | getContextpath() |
Get url | getRequestURI() relative path--getRequestURL() absolute path |
Get the value of the request header | getHeader(String name); |
Get the names of all request headers | getHeadernames(); |
Get stream
effect | Code |
---|---|
Character stream | getrReader() |
Byte stream | getIntputStream () |
Get request parameters
effect | Code |
---|---|
Get the value based on the parameter name | getParmeter(String name); |
Get the value array based on the parameter name | getParmeterValues(String name); |
Get the map collection of all parameters | getParmetermap(); |
Request forwarding
effect | Code |
---|---|
Get transponder object | getRequestDispatcher(String path) |
Forwarding using forwarder object | forward(request,response) |
basic function
effect | Code |
---|---|
Storing data | setAttribute(String name,Object obj) |
Get by key value | getAttitude(String nam) |
Remove by key value | removeAttibute(String name) |