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

public @Interface PathVariable

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

Annotation which indicates that a method parameter should be bound to a URI template variable. Supported for RequestMapping annotated handler methods.

If the method parameter is Map<String, String> then the map is populated with all path variable names and values.

Authors
Arjen Poutsma, Juergen Hoeller
Since
3.0
See Also
RequestMapping, org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter

Method Summary

Modifier and TypeMethod and Description
public String
name()

The name of the path variable to bind to.

public boolean
required()

Whether the path variable is required.

public String
value()

Alias for name.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

nameback to summary
public String name()

The name of the path variable to bind to.

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

Whether the path variable is required.

Defaults to true, leading to an exception being thrown if the path variable is missing in the incoming request. Switch this to false if you prefer a null or Java 8 java.util.Optional in this case. e.g. on a ModelAttribute method which serves for different requests.

Since
4.3.3
valueback to summary
public String value()

Alias for name.

Annotations
@AliasFor:name