public class HttpUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addCookies(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String cookieName,
String cookieDomain,
int maxAge,
String cookieValue)
增加cookie
|
static void |
addCookies(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String cookieName,
String cookieDomain,
int maxAge,
String cookieValue,
String cookiePath)
增加cookie
|
static javax.servlet.http.Cookie |
createCookie(String cookieName,
String cookieValue,
boolean isSecure,
String path,
String domain,
int maxAge)
构造cookie
|
static javax.servlet.http.Cookie |
findCookieByName(javax.servlet.http.HttpServletRequest request,
String cookieName)
通过名称查找cookie
|
static String |
findCookieValue(javax.servlet.http.HttpServletRequest request,
String cookingName)
通过cookie名称查找cookie值
|
static String |
getCookiePath(javax.servlet.http.HttpServletRequest request)
获取cookie路径
|
static String |
getFilename(javax.servlet.http.Part part)
从multi-part中获取文件名称
|
static Map<String,String> |
getHeaders(javax.servlet.http.HttpServletRequest request)
获取请求头部信息
|
static Map<String,String> |
getHeaders(javax.servlet.http.HttpServletResponse response)
获取返回头部信息
|
static Set<String> |
getParamNames(javax.servlet.http.HttpServletRequest request)
获取参数名称
|
static Map<String,String> |
getParams(javax.servlet.http.HttpServletRequest request)
获取请求参数
|
static Map<String,String> |
getParams(String queryString)
从queryString中获取参数
|
static String |
getQueryString(Map<String,String> params,
Collection<String> ignoredParamNames)
获取query string
|
static String |
getRealIp(javax.servlet.http.HttpServletRequest request)
获取真实ip(经过nginx后)
|
public static String getRealIp(javax.servlet.http.HttpServletRequest request)
request - 请求public static Map<String,String> getParams(javax.servlet.http.HttpServletRequest request)
request - 请求public static Map<String,String> getHeaders(javax.servlet.http.HttpServletRequest request)
request - 请求public static Map<String,String> getHeaders(javax.servlet.http.HttpServletResponse response)
response - 返回public static Set<String> getParamNames(javax.servlet.http.HttpServletRequest request)
request - 请求public static Map<String,String> getParams(String queryString)
queryString - query stringpublic static String getFilename(javax.servlet.http.Part part)
part - 文件partpublic static javax.servlet.http.Cookie findCookieByName(javax.servlet.http.HttpServletRequest request,
String cookieName)
request - 请求cookieName - cookie名称public static String findCookieValue(javax.servlet.http.HttpServletRequest request, String cookingName)
request - 请求cookingName - cookie名称public static String getCookiePath(javax.servlet.http.HttpServletRequest request)
request - 请求public static javax.servlet.http.Cookie createCookie(String cookieName, String cookieValue, boolean isSecure, String path, String domain, int maxAge)
cookieName - cookie名称cookieValue - cookie值isSecure - 是否安全连接path - cookie路径domain - cookie域maxAge - cookie过期时间(秒)public static void addCookies(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String cookieName,
String cookieDomain,
int maxAge,
String cookieValue)
request - 请求response - 返回cookieName - cookie名称cookieDomain - cookie域,多个用","分割maxAge - cookie过期时间(秒)cookieValue - cookie值public static void addCookies(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String cookieName,
String cookieDomain,
int maxAge,
String cookieValue,
String cookiePath)
request - 请求response - 返回cookieName - cookie名称cookieDomain - cookie域,多个用","分割maxAge - cookie过期时间(秒)cookieValue - cookie值cookiePath - cookie路径Copyright © 2020 IBIT程序猿. All rights reserved.