request获得请求行的内容
String method = request.getMethod();
String URI = request.getRequestURI();
String URL = request.getRequestURL();
String contextPath = request.getContextPath();
String ip = request.getRemoteAddr();
request获得请求头的内容
String value = request.getHeader(String name);
request获得请求体(参数)的内容
String parameter = request.getParameter(String name);
String[] parameters = request.getParameterValues(String name);
Map<String,String[]> map = request.getParameterMap();
request转发和域
RequestDispatcher dispatcher = request.getRequestDispatcher(String url);
dispatcher.forward(request,reponse);
request
是一个域对象
生命周期:客户端发出一次请求时创建,在这一次请求结束时销毁。
方法:
request.setAttribute(String name,String value);
request.getAttribute(String name);
request.removeAttribute(String name);