注释类型 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 forRequestMapping
annotated handler methods.If the method parameter is
Map<String, String>
then the map is populated with all path variable names and values.- 从以下版本开始:
- 3.0
- 作者:
- Arjen Poutsma, Juergen Hoeller
- 另请参阅:
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 tofalse
if you prefer anull
or Java 8java.util.Optional
in this case. e.g. on aModelAttribute
method which serves for different requests.- 从以下版本开始:
- 4.3.3
- 默认值:
- true