类 WebUtil
- java.lang.Object
-
- org.springframework.web.util.WebUtils
-
- cn.meteor.common.web.util.WebUtil
-
public class WebUtil extends org.springframework.web.util.WebUtilsMiscellaneous utilities for web applications.- 从以下版本开始:
- 1.0.0
- 作者:
- ths
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringDEFAULT_USER_TYPEstatic StringHEADER_KEYstatic StringHEADER_PREFIXstatic StringUN_KNOWNstatic StringUSER_AGENT_HEADERstatic StringUSER_TYPE_HEADER_KEY-
从类继承的字段 org.springframework.web.util.WebUtils
CONTENT_TYPE_CHARSET_PREFIX, DEFAULT_CHARACTER_ENCODING, DEFAULT_WEB_APP_ROOT_KEY, ERROR_EXCEPTION_ATTRIBUTE, ERROR_EXCEPTION_TYPE_ATTRIBUTE, ERROR_MESSAGE_ATTRIBUTE, ERROR_REQUEST_URI_ATTRIBUTE, ERROR_SERVLET_NAME_ATTRIBUTE, ERROR_STATUS_CODE_ATTRIBUTE, FORWARD_CONTEXT_PATH_ATTRIBUTE, FORWARD_PATH_INFO_ATTRIBUTE, FORWARD_QUERY_STRING_ATTRIBUTE, FORWARD_REQUEST_URI_ATTRIBUTE, FORWARD_SERVLET_PATH_ATTRIBUTE, HTML_ESCAPE_CONTEXT_PARAM, INCLUDE_CONTEXT_PATH_ATTRIBUTE, INCLUDE_PATH_INFO_ATTRIBUTE, INCLUDE_QUERY_STRING_ATTRIBUTE, INCLUDE_REQUEST_URI_ATTRIBUTE, INCLUDE_SERVLET_PATH_ATTRIBUTE, RESPONSE_ENCODED_HTML_ESCAPE_CONTEXT_PARAM, SESSION_MUTEX_ATTRIBUTE, SUBMIT_IMAGE_SUFFIXES, TEMP_DIR_CONTEXT_ATTRIBUTE, WEB_APP_ROOT_KEY_PARAM
-
-
构造器概要
构造器 构造器 说明 WebUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static StringgetCookieVal(String name)读取cookiestatic StringgetCookieVal(javax.servlet.http.HttpServletRequest request, String name)读取cookiestatic StringgetHeader(String headerKey)获取 headerValuestatic StringgetIp()获取ipstatic StringgetIp(javax.servlet.http.HttpServletRequest request)获取ipstatic javax.servlet.http.HttpServletRequestgetRequest()获取 HttpServletRequeststatic byte[]getRequestBytes(javax.servlet.http.HttpServletRequest request)获取 request 请求的 byte[] 数组static StringgetRequestParamString(javax.servlet.http.HttpServletRequest request)获取 request 中 json 字符串的内容static StringgetRequestStr(javax.servlet.http.HttpServletRequest request)获取 request 请求内容static StringgetRequestStr(javax.servlet.http.HttpServletRequest request, byte[] buffer)获取 request 请求内容static booleanisBody(org.springframework.web.method.HandlerMethod handlerMethod)判断是否ajax请求 spring ajax 返回含有 ResponseBody 或者 RestController注解static voidremoveCookie(javax.servlet.http.HttpServletResponse response, String key)清除 某个指定的cookiestatic voidrenderJson(javax.servlet.http.HttpServletResponse response, Object result)返回jsonstatic voidrenderJson(javax.servlet.http.HttpServletResponse response, Object result, String contentType)返回jsonstatic voidsetCookie(javax.servlet.http.HttpServletResponse response, String name, String value, int maxAgeInSeconds)设置cookie-
从类继承的方法 org.springframework.web.util.WebUtils
clearErrorRequestAttributes, exposeErrorRequestAttributes, findParameterValue, findParameterValue, getCookie, getDefaultHtmlEscape, getNativeRequest, getNativeResponse, getParametersStartingWith, getRealPath, getRequiredSessionAttribute, getResponseEncodedHtmlEscape, getSessionAttribute, getSessionId, getSessionMutex, getTempDir, hasSubmitParameter, isIncludeRequest, isSameOrigin, isValidOrigin, parseMatrixVariables, removeWebAppRootSystemProperty, setSessionAttribute, setWebAppRootSystemProperty
-
-
-
-
方法详细资料
-
isBody
public static boolean isBody(org.springframework.web.method.HandlerMethod handlerMethod)
判断是否ajax请求 spring ajax 返回含有 ResponseBody 或者 RestController注解- 参数:
handlerMethod- HandlerMethod- 返回:
- 是否ajax请求
-
getCookieVal
@Nullable public static String getCookieVal(String name)
读取cookie- 参数:
name- cookie name- 返回:
- cookie value
-
getCookieVal
@Nullable public static String getCookieVal(javax.servlet.http.HttpServletRequest request, String name)
读取cookie- 参数:
request- HttpServletRequestname- cookie name- 返回:
- cookie value
-
removeCookie
public static void removeCookie(javax.servlet.http.HttpServletResponse response, String key)清除 某个指定的cookie- 参数:
response- HttpServletResponsekey- cookie key
-
setCookie
public static void setCookie(javax.servlet.http.HttpServletResponse response, String name, @Nullable String value, int maxAgeInSeconds)设置cookie- 参数:
response- HttpServletResponsename- cookie namevalue- cookie valuemaxAgeInSeconds- maxage
-
getRequest
public static javax.servlet.http.HttpServletRequest getRequest()
获取 HttpServletRequest- 返回:
- {HttpServletRequest}
-
getHeader
public static String getHeader(String headerKey)
获取 headerValue- 参数:
headerKey- headerKey- 返回:
- {headerValue}
-
renderJson
public static void renderJson(javax.servlet.http.HttpServletResponse response, Object result)返回json- 参数:
response- HttpServletResponseresult- 结果对象
-
renderJson
public static void renderJson(javax.servlet.http.HttpServletResponse response, Object result, String contentType)返回json- 参数:
response- HttpServletResponseresult- 结果对象contentType- contentType
-
getIp
public static String getIp()
获取ip- 返回:
- {String}
-
getIp
@Nullable public static String getIp(javax.servlet.http.HttpServletRequest request)
获取ip- 参数:
request- HttpServletRequest- 返回:
- {String}
-
getRequestParamString
public static String getRequestParamString(javax.servlet.http.HttpServletRequest request)
获取 request 中 json 字符串的内容- 参数:
request- request- 返回:
- 字符串内容
-
getRequestStr
public static String getRequestStr(javax.servlet.http.HttpServletRequest request) throws IOException
获取 request 请求内容- 参数:
request- request- 返回:
- String
- 抛出:
IOException- IOException
-
getRequestBytes
public static byte[] getRequestBytes(javax.servlet.http.HttpServletRequest request) throws IOException获取 request 请求的 byte[] 数组- 参数:
request- request- 返回:
- byte[]
- 抛出:
IOException- IOException
-
getRequestStr
public static String getRequestStr(javax.servlet.http.HttpServletRequest request, byte[] buffer) throws IOException
获取 request 请求内容- 参数:
request- requestbuffer- buffer- 返回:
- String
- 抛出:
IOException- IOException
-
-