Class ServletCookieValueMethodArgumentResolver
java.lang.Object
org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver
org.springframework.web.servlet.mvc.method.annotation.ServletCookieValueMethodArgumentResolver
- All Implemented Interfaces:
HandlerMethodArgumentResolver
public class ServletCookieValueMethodArgumentResolver
extends AbstractCookieValueMethodArgumentResolver
An
AbstractCookieValueMethodArgumentResolver
that resolves cookie values from an HttpServletRequest
.- Since:
- 3.1
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
AbstractNamedValueMethodArgumentResolver.NamedValueInfo
-
Constructor Summary
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
resolveName
(String cookieName, MethodParameter parameter, NativeWebRequest webRequest) Resolve the given parameter type and value name into an argument value.void
setUrlDecode
(boolean urlDecode) Whether to apply URL decoding to cookie values viaUrlPathHelper.decodeRequestString(HttpServletRequest, String)
.void
setUrlPathHelper
(UrlPathHelper urlPathHelper) Set theUrlPathHelper
to use to decode cookie values with viaUrlPathHelper.decodeRequestString(HttpServletRequest, String)
.Methods inherited from class org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver
createNamedValueInfo, handleMissingValue, handleMissingValueAfterConversion, supportsParameter
Methods inherited from class org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
handleMissingValue, handleResolvedValue, resolveArgument
-
Constructor Details
-
ServletCookieValueMethodArgumentResolver
-
-
Method Details
-
setUrlDecode
public void setUrlDecode(boolean urlDecode) Whether to apply URL decoding to cookie values viaUrlPathHelper.decodeRequestString(HttpServletRequest, String)
. A shortcut for doing the same by setting aUrlPathHelper
with itsurlDecode
property set accordingly.By default set to "true" in which case cookie values are decoded.
- Since:
- 6.1.2
-
setUrlPathHelper
Set theUrlPathHelper
to use to decode cookie values with viaUrlPathHelper.decodeRequestString(HttpServletRequest, String)
. For most cases you can usesetUrlDecode(boolean)
instead. -
resolveName
@Nullable protected Object resolveName(String cookieName, MethodParameter parameter, NativeWebRequest webRequest) throws Exception Description copied from class:AbstractNamedValueMethodArgumentResolver
Resolve the given parameter type and value name into an argument value.- Specified by:
resolveName
in classAbstractNamedValueMethodArgumentResolver
- Parameters:
cookieName
- the name of the value being resolvedparameter
- the method parameter to resolve to an argument value (pre-nested in case of aOptional
declaration)webRequest
- the current request- Returns:
- the resolved argument (may be
null
) - Throws:
Exception
- in case of errors
-