Top Description Methods
org.springframework.web.servlet.support

public Interface RequestDataValueProcessor

Imports
java.util.Map, jakarta.servlet.http.HttpServletRequest, org.springframework.lang.Nullable

A contract for inspecting and potentially modifying request data values such as URL query parameters or form field values before they are rendered by a view or before a redirect.

Implementations may use this contract for example as part of a solution to provide data integrity, confidentiality, protection against cross-site request forgery (CSRF), and others or for other tasks such as automatically adding a hidden field to all forms and URLs.

View technologies that support this contract can obtain an instance to delegate to via RequestContext#getRequestDataValueProcessor().

Author
Rossen Stoyanchev
Since
3.1

Method Summary

Modifier and TypeMethod and Description
public Map<String, String>

Returns:

additional hidden form fields to be added, or null if none
getExtraHiddenFields
(HttpServletRequest
the current request
request
)

Invoked after all form fields have been rendered.

public String

Returns:

the action to use, possibly modified
processAction
(HttpServletRequest
the current request
request
,
String
the form action
action
,
String
the form HTTP method
httpMethod
)

Invoked when a new form action is rendered.

public String

Returns:

the form field value to use, possibly modified
processFormFieldValue
(HttpServletRequest
the current request
request
,
String
the form field name (if any)
name
,
String
the form field value
value
,
String
the form field type ("text", "hidden", etc.)
type
)

Invoked when a form field value is rendered.

public String

Returns:

the URL to use, possibly modified
processUrl
(HttpServletRequest
the current request
request
,
String
the URL value
url
)

Invoked when a URL is about to be rendered or redirected to.

Method Detail

getExtraHiddenFieldsback to summary
public Map<String, String> getExtraHiddenFields(HttpServletRequest request)

Invoked after all form fields have been rendered.

Parameters
request:HttpServletRequest

the current request

Returns:Map<String, String>

additional hidden form fields to be added, or null if none

Annotations
@Nullable
processActionback to summary
public String processAction(HttpServletRequest request, String action, String httpMethod)

Invoked when a new form action is rendered.

Parameters
request:HttpServletRequest

the current request

action:String

the form action

httpMethod:String

the form HTTP method

Returns:String

the action to use, possibly modified

processFormFieldValueback to summary
public String processFormFieldValue(HttpServletRequest request, String name, String value, String type)

Invoked when a form field value is rendered.

Parameters
request:HttpServletRequest

the current request

name:String

the form field name (if any)

value:String

the form field value

type:String

the form field type ("text", "hidden", etc.)

Returns:String

the form field value to use, possibly modified

processUrlback to summary
public String processUrl(HttpServletRequest request, String url)

Invoked when a URL is about to be rendered or redirected to.

Parameters
request:HttpServletRequest

the current request

url:String

the URL value

Returns:String

the URL to use, possibly modified