Annotation Type PathVariable
@Target(PARAMETER) @Retention(RUNTIME) @Documented public @interface PathVariable
Annotation which indicates that a method parameter should be bound to a URI template variable. Supported forRequestMappingannotated handler methods.If the method parameter is
Map<String, String>then the map is populated with all path variable names and values.- Since:
- 3.0
- Author:
- Arjen Poutsma, Juergen Hoeller
- See Also:
RequestMapping,RequestMappingHandlerAdapter
required
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 tofalseif you prefer anullor Java 8java.util.Optionalin this case. e.g. on aModelAttributemethod which serves for different requests.- Since:
- 4.3.3
- Default:
- true