Class RequestAttributes
The RequestAttributes
object is the API for accessing the standard servlet attributes on an HTTP request
(i.e. ServletRequest.getAttribute(String)
).
Example:
Some important methods on this class are:
RequestHeaders
- Methods for retrieving request attributes:
- Methods for overriding request attributes:
- Other methods:
Modifications made to request attributes through the
See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDefault
(String name, Object value) Adds a default entry to the request attributes.addDefault
(List<NamedAttribute> pairs) Adds default entries to the request attributes.addDefault
(NamedAttribute... pairs) Adds default entries to the request attributes.addDefault
(NamedAttributeMap pairs) Adds default entries to the request attributes.asMap()
Returns the request attributes as a map.boolean
Returnstrue if the attributes with the specified names are present.boolean
containsAny
(String... names) Returnstrue if the attribute with any of the specified names are present.Returns the request attribute with the specified name.getAll()
Returns all the attribute on this request.Remove request attributes.remove
(NamedAttribute... attributes) Remove request attributes.Sets a request attribute.set
(NamedAttribute... attributes) Sets request attributes.toString()
-
Constructor Details
-
RequestAttributes
Constructor.- Parameters:
req
- The request creating this bean.
-
-
Method Details
-
addDefault
Adds default entries to the request attributes.- Parameters:
pairs
- The default entries.
Can benull .- Returns:
- This object.
-
addDefault
Adds default entries to the request attributes.- Parameters:
pairs
- The default entries.
Can benull .- Returns:
- This object.
-
addDefault
Adds default entries to the request attributes.- Parameters:
pairs
- The default entries.
Can benull .- Returns:
- This object.
-
addDefault
Adds a default entry to the request attributes.- Parameters:
name
- The name.value
- The value.- Returns:
- This object.
-
get
Returns the request attribute with the specified name.- Parameters:
name
- The attribute name.- Returns:
- The parameter value, or
Optional.empty()
if it doesn't exist.
-
getAll
Returns all the attribute on this request.- Returns:
- All the attribute on this request.
-
contains
Returnstrue if the attributes with the specified names are present.- Parameters:
names
- The attribute names. Must not benull .- Returns:
true if the parameters with the specified names are present.
-
containsAny
Returnstrue if the attribute with any of the specified names are present.- Parameters:
names
- The attribute names. Must not benull .- Returns:
true if the attribute with any of the specified names are present.
-
set
Sets a request attribute.- Parameters:
name
- The attribute name. Must not benull .value
- The attribute value.
Can benull .- Returns:
- This object.
-
set
Sets request attributes.- Parameters:
attributes
- The parameters to set. Must not benull or containnull .- Returns:
- This object.
-
remove
Remove request attributes.- Parameters:
name
- The attribute names. Must not benull .- Returns:
- This object.
-
remove
Remove request attributes.- Parameters:
attributes
- The attributes to remove. Must not benull .- Returns:
- This object.
-
asMap
Returns the request attributes as a map.- Returns:
- The request attributes as a map. Never
null .
-
toString
-