申请
客户端申请由ServletRequest类型的request对象示意,在HTTP申请场景下,容器提供的申请对象的具体类型为HttpServletRequest
HTTP的申请音讯分为三局部:申请行、申请头、申请注释。
<!– more –>
申请行对应办法
// 获取申请行中的协定名和版本
public String getProtocol();
// 获取申请形式
public String getMethod();
// url中的额定门路信息
public String getPathInfo();
// url中的额定门路信息多对应的资源的真是门路
public String getPathTranslated();
// 获取申请URL所属的WEB应用程序门路,以/结尾,示意整个web站点的根目录
public String getContextPath();
// 申请行中的参数
public String getQueryString();
// 获取申请行中的资源名,主机端口之后,参数之前的局部
public String getRequestURI();
// 获取Servlet所映射的门路
public String getServletPath();
网络连接信息相干办法
// 客户端的ip
public String getRemoteAddr();
//客户端的主机
public String getRemoteHost();
//客户端的端口
public int getRemotePort();
// 服务器接管以后申请的网络接口的ip对应的主机名
public String getLocalName();
// 服务器接管以后申请的网络接口的ip
public String getLocalAddr();
// 服务器接管以后申请的网络接口的端口
public int getLocalPort();
// 获取URL
public StringBuffer getRequestURL();
// 以后申请所指向的主机名
public String getServerName();
// 以后申请所连贯的服务器端口号
public int getServerPort();
// 协定名
public String getScheme();
申请头信息
// 获取申请头
public long getDateHeader(String name);
public String getHeader(String name);
public Enumeration<String> getHeaders(String name);
public Enumeration<String> getHeaderNames();
public int getIntHeader(String name);
// 获取Content-Length头字段信息
public int getContentLength();
// 返回Content-Type头字段信息
public String getContentType();
// 返回申请音讯的字符集编码,Content-Type头字段信息
public String getCharacterEncoding();
public String getAuthType();
public Cookie[] getCookies();
public String getRemoteUser();
public boolean isUserInRole(String role);
public java.security.Principal getUserPrincipal();
public String getRequestedSessionId();
public HttpSession getSession(boolean create);
public HttpSession getSession();
public String changeSessionId();
public boolean isRequestedSessionIdValid();
public boolean isRequestedSessionIdFromCookie();
public boolean isRequestedSessionIdFromURL();
public boolean isRequestedSessionIdFromUrl();
public boolean authenticate(HttpServletResponse response)
throws IOException,ServletException;
public void login(String username, String password)
throws ServletException;
public void logout() throws ServletException;
public Collection<Part> getParts() throws IOException, ServletException;
public Part getPart(String name) throws IOException, ServletException;
public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass)
throws IOException, ServletException;
获取申请参数
// 读取url地址后的参数或者POST申请中application/x-www-form-urlencoded编码的实体
// 能够对编码内容主动实现参数的合成、提取以及解码
public String getParameter(String name);
public Enumeration<String> getParameterNames();
public String[] getParameterValues(String name);
public Map<String, String[]> getParameterMap();
// 获取流对象
public ServletInputStream getInputStream() throws IOException;
public BufferedReader getReader() throws IOException;
https://zhhll.icu/2021/javaweb/根底/2.申请/
本文由mdnice多平台公布
发表回复