Top Description Methods
org.springframework.web.bind.annotation

public @Interface RequestParam

extends Annotation
Annotations
@Target:PARAMETER
@Retention:RUNTIME
@Documented
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, java.util.Map, org.springframework.core.annotation.AliasFor

Annotation which indicates that a method parameter should be bound to a web request parameter.

Supported for annotated handler methods in Spring MVC and Spring WebFlux as follows:

If the method parameter type is Map and a request parameter name is specified, then the request parameter value is converted to a Map assuming an appropriate conversion strategy is available.

If the method parameter is Map<String, String> or MultiValueMap<String, String> and a parameter name is not specified, then the map parameter is populated with all request parameter names and values.

Authors
Arjen Poutsma, Juergen Hoeller, Sam Brannen
Since
2.5
See Also
RequestMapping, RequestHeader, CookieValue

Method Summary

Modifier and TypeMethod and Description
public String
defaultValue()

The default value to use as a fallback when the request parameter is not provided or has an empty value.

public String
name()

The name of the request parameter to bind to.

public boolean
required()

Whether the parameter is required.

public String
value()

Alias for name.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

defaultValueback to summary
public String defaultValue()

The default value to use as a fallback when the request parameter is not provided or has an empty value.

Supplying a default value implicitly sets required to false.

nameback to summary
public String name()

The name of the request parameter to bind to.

Annotations
@AliasFor:value
Since
4.2
requiredback to summary
public boolean required()

Whether the parameter is required.

Defaults to true, leading to an exception being thrown if the parameter is missing in the request. Switch this to false if you prefer a null value if the parameter is not present in the request.

Alternatively, provide a defaultValue, which implicitly sets this flag to false.

valueback to summary
public String value()

Alias for name.

Annotations
@AliasFor:name