类 WebUtils
Used by various framework classes.
- 从以下版本开始:
- 4.0
- 作者:
- Rod Johnson, Juergen Hoeller, Sebastien Deleuze, Sam Brannen, Harry Yang
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidcleanupMultipartRequest(cn.taketoday.util.MultiValueMap<String, Multipart> multipartFiles) decodeMatrixVariables(cn.taketoday.util.MultiValueMap<String, String> vars) Decode the given matrix variablesdecodePathVariables(Map<String, String> vars) Decode the given URI path variablesstatic <T> TgetNativeContext(RequestContext request, Class<T> requiredType) Return an appropriate request object of the specified type, if available, unwrapping the given request as far as necessary.private static intstatic StringgetSanitizedPath(String path) Sanitize the given path.static ObjectgetSessionMutex(WebSession session) Return the best available mutex for the given session: that is, an object to synchronize on for the given session.static booleanisSameOrigin(RequestContext request) Check if the request is a same-origin one, based onOrigin,Host,Forwarded,X-Forwarded-Proto,X-Forwarded-HostandX-Forwarded-Portheaders.static booleanisValidOrigin(RequestContext request, Collection<String> allowedOrigins) Check the given request origin against a list of allowed origins.parseMatrixVariables(String matrixVariables) Parse the given string with matrix variables.static StringremoveSemicolonContent(String lookupPath) Remove ";" (semicolon) content from the given request URI
-
字段详细资料
-
ERROR_MESSAGE_ATTRIBUTE
-
ERROR_EXCEPTION_ATTRIBUTE
-
CONTENT_TYPE_CHARSET_PREFIX
Prefix of the charset clause in a content type String: ";charset=".- 另请参阅:
-
SESSION_MUTEX_ATTRIBUTE
Key for the mutex session attribute.
-
-
构造器详细资料
-
WebUtils
public WebUtils()
-
-
方法详细资料
-
getSessionMutex
Return the best available mutex for the given session: that is, an object to synchronize on for the given session.The session mutex is guaranteed to be the same object during the entire lifetime of the session, available under the key defined by the
SESSION_MUTEX_ATTRIBUTEconstant. It serves as a safe reference to synchronize on for locking on the current session.In many cases, the WebSession reference itself is a safe mutex as well, since it will always be the same object reference for the same active logical session. However, this is not guaranteed across different servlet containers; the only 100% safe way is a session mutex.
- 参数:
session- the WebSession to find a mutex for- 返回:
- the mutex object (never
null) - 另请参阅:
-
parseMatrixVariables
public static cn.taketoday.util.MultiValueMap<String,String> parseMatrixVariables(String matrixVariables) Parse the given string with matrix variables. An example string would look like this"q1=a;q1=b;q2=a,b,c". The resulting map would contain keys"q1"and"q2"with values["a","b"]and["a","b","c"]respectively.- 参数:
matrixVariables- the unparsed matrix variables string- 返回:
- a map with matrix variable names and values (never
null)
-
getNativeContext
@Nullable public static <T> T getNativeContext(RequestContext request, @Nullable Class<T> requiredType) Return an appropriate request object of the specified type, if available, unwrapping the given request as far as necessary.- 参数:
request- the RequestContext to introspectrequiredType- the desired type of request object- 返回:
- the matching request object, or
nullif none of that type is available
-
getSanitizedPath
Sanitize the given path. Uses the following rules:- replace all "//" by "/"
-
decodePathVariables
Decode the given URI path variables- 参数:
vars- the URI variables extracted from the URL path- 返回:
- the same Map or a new Map instance
-
decodeMatrixVariables
public static cn.taketoday.util.MultiValueMap<String,String> decodeMatrixVariables(cn.taketoday.util.MultiValueMap<String, String> vars) Decode the given matrix variables- 参数:
vars- the URI variables extracted from the URL path- 返回:
- the same Map or a new Map instance
-
removeSemicolonContent
Remove ";" (semicolon) content from the given request URI- 参数:
lookupPath- the request URI string to remove ";" content from- 返回:
- the updated URI string
-
isValidOrigin
Check the given request origin against a list of allowed origins. A list containing "*" means that all origins are allowed. An empty list means only same origin is allowed.Note: this method ignores
"Forwarded"and"X-Forwarded-*"headers that specify the client-originated address. Consider using theForwardedHeaderFilterto extract and use, or to discard such headers.- 返回:
trueif the request origin is valid,falseotherwise- 另请参阅:
-
isSameOrigin
Check if the request is a same-origin one, based onOrigin,Host,Forwarded,X-Forwarded-Proto,X-Forwarded-HostandX-Forwarded-Portheaders.Note: this method ignores
"Forwarded"and"X-Forwarded-*"headers that specify the client-originated address. Consider using theForwardedHeaderFilterto extract and use, or to discard such headers.- 返回:
trueif the request is a same-origin one,falsein case of cross-origin request
-
getPort
-
cleanupMultipartRequest
-