Class RequestHelper
-
- All Implemented Interfaces:
public class RequestHelperType-safe to get the value in the request.
- Since:
2019-07-03
trydofor
-
-
Constructor Summary
Constructors Constructor Description RequestHelper()
-
Method Summary
Modifier and Type Method Description static StringallErrors(@NotNull() BindingResult error)Construct all error messages in `\n` delimited `(error=)?message` format. static StringgetCookieValue(HttpServletRequest request, String name)static Map<String, String>mapCookieValue(HttpServletRequest request)static Map<String, Set<String>>allCookieValue(HttpServletRequest request)static <T> TgetAttribute(HttpServletRequest request, String name, Class<T> claz)static <T> TgetAttribute(HttpServletRequest request, String name)static <T> TgetAttributeIgnoreCase(HttpServletRequest request, String name)static <T> TgetAttributeIgnoreCase(HttpServletRequest request, String name, Class<T> claz)static StringgetRemoteIp(HttpServletRequest request, Array<String> header)static booleanmatchIgnoreCase(HttpServletRequest req, String path)Case-insensitive matching of URI with path, support for wildcard static booleanmatchIgnoreCase(HttpServletRequest req, Array<String> path)Case-insensitive matching of URI with any of path, support for wildcard static StringgetParameter(Map<String, Array<String>> param, String name)static Array<String>getParameters(Map<String, Array<String>> param, String name)static Map<String, String>getParameter(Map<String, Array<String>> param)static StringgetAccessToken(HttpServletRequest request)First get `Bearer` in Header, if not found, then get `access_token` in Parameter `Bearer` and `access_token` are case-insensitive, if there is more than one token, take the last one. static booleanisForwarding(HttpServletRequest request)static InputStreamtryCircleInputStream(ServletRequest request)static BufferedReadertryCircleBufferedReader(ServletRequest request)-
-
Method Detail
-
allErrors
static String allErrors(@NotNull() BindingResult error)
Construct all error messages in `\n` delimited `(error=)?message` format.
- Parameters:
error- error message- Returns:
null if no error
-
getCookieValue
@Nullable() static String getCookieValue(HttpServletRequest request, String name)
-
mapCookieValue
@NotNull() static Map<String, String> mapCookieValue(HttpServletRequest request)
-
allCookieValue
@NotNull() static Map<String, Set<String>> allCookieValue(HttpServletRequest request)
-
getAttribute
@Nullable() static <T> T getAttribute(HttpServletRequest request, String name, Class<T> claz)
-
getAttribute
@Nullable() static <T> T getAttribute(HttpServletRequest request, String name)
-
getAttributeIgnoreCase
@Nullable() static <T> T getAttributeIgnoreCase(HttpServletRequest request, String name)
-
getAttributeIgnoreCase
@Nullable() static <T> T getAttributeIgnoreCase(HttpServletRequest request, String name, Class<T> claz)
-
getRemoteIp
@NotNull() static String getRemoteIp(HttpServletRequest request, Array<String> header)
-
matchIgnoreCase
static boolean matchIgnoreCase(HttpServletRequest req, String path)
Case-insensitive matching of URI with path, support for wildcard
- Parameters:
req- the requestpath- path pattern, return false if null or empty- Returns:
whether matches
-
matchIgnoreCase
static boolean matchIgnoreCase(HttpServletRequest req, Array<String> path)
Case-insensitive matching of URI with any of path, support for wildcard
- Parameters:
req- the requestpath- path patterns, return false if null or empty- Returns:
whether matches any
-
getParameters
@NotNull() static Array<String> getParameters(Map<String, Array<String>> param, String name)
-
getAccessToken
@Nullable() static String getAccessToken(HttpServletRequest request)
First get `Bearer` in Header, if not found, then get `access_token` in Parameter `Bearer` and `access_token` are case-insensitive, if there is more than one token, take the last one.
-
isForwarding
static boolean isForwarding(HttpServletRequest request)
-
tryCircleInputStream
static InputStream tryCircleInputStream(ServletRequest request)
-
tryCircleBufferedReader
static BufferedReader tryCircleBufferedReader(ServletRequest request)
-
-
-
-