Top Description Fields Constructors Methods
org.springframework.web.servlet.mvc.method.annotation

public Class ServletCookieValueMethodArgumentResolver

extends AbstractCookieValueMethodArgumentResolver
Class Inheritance
Imports
jakarta.servlet.http.Cookie, .HttpServletRequest, org.springframework.beans.factory.config.ConfigurableBeanFactory, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver, org.springframework.web.util.UrlPathHelper, .WebUtils

An org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver that resolves cookie values from an HttpServletRequest.
Author
Rossen Stoyanchev
Since
3.1

Field Summary

Modifier and TypeField and Description
private UrlPathHelper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Object
resolveName(String
the name of the value being resolved
cookieName
,
MethodParameter
the method parameter to resolve to an argument value (pre-nested in case of a java.util.Optional declaration)
parameter
,
NativeWebRequest
the current request
webRequest
)

Implements abstract org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveName.

Resolve the given parameter type and value name into an argument value.

public void
setUrlDecode(boolean urlDecode)

Whether to apply URL decoding to cookie values via UrlPathHelper#decodeRequestString(HttpServletRequest, String).

public void
setUrlPathHelper(UrlPathHelper urlPathHelper)

Set the UrlPathHelper to use to decode cookie values with via UrlPathHelper#decodeRequestString(HttpServletRequest, String).

Inherited from org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver:
createNamedValueInfohandleMissingValuehandleMissingValueAfterConversionsupportsParameter

Field Detail

urlPathHelperback to summary
private UrlPathHelper urlPathHelper

Constructor Detail

ServletCookieValueMethodArgumentResolverback to summary
public ServletCookieValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory)

Method Detail

resolveNameback to summary
protected Object resolveName(String cookieName, MethodParameter parameter, NativeWebRequest webRequest) throws Exception

Implements abstract org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveName.

Doc from org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveName.

Resolve the given parameter type and value name into an argument value.

Parameters
cookieName:String

the name of the value being resolved

parameter:MethodParameter

the method parameter to resolve to an argument value (pre-nested in case of a java.util.Optional declaration)

webRequest:NativeWebRequest

the current request

Returns:Object

the resolved argument (may be null)

Annotations
@Override
@Nullable
Exceptions
Exception:
in case of errors
setUrlDecodeback to summary
public void setUrlDecode(boolean urlDecode)

Whether to apply URL decoding to cookie values via UrlPathHelper#decodeRequestString(HttpServletRequest, String). A shortcut for doing the same by setting a UrlPathHelper with its urlDecode property set accordingly.

By default set to "true" in which case cookie values are decoded.

Since
6.1.2
setUrlPathHelperback to summary
public void setUrlPathHelper(UrlPathHelper urlPathHelper)

Set the UrlPathHelper to use to decode cookie values with via UrlPathHelper#decodeRequestString(HttpServletRequest, String). For most cases you can use setUrlDecode(boolean) instead.