When I add the default value of the string in JAX-RS, it doesn't take the value. It stays to null or empty.
@QueryParam("status")
private String status = "confirmed";
When I pass the status as empty or null
or undefined it stays as empty or null
or undefined. It doesn't take the default as confirmed.
Use the @DefaultValue
annotation to specify the default value of the request meta-data that is bound to @PathParam
, @QueryParam
, @MatrixParam
, @CookieParam
, @FormParam
and @HeaderParam
annotations:
@QueryParam("status")
@DefaultValue("confirmed")
private String status;
If a method parameter, resource class field, or resource class bean property is not annotated with @DefaultValue
and the corresponding meta-data is not present in the request, the value will be:
List
, Set
or SortedSet
. null
for other object types;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.