For example, having the following Java rest definition:
@GET
@Path("/something")
public String somthing(
@QueryParam("valString") String valString,
@QueryParam("valInt") int valInt,
@QueryParam("valBool") boolean valBool
) {
...
}
And invocation:
curl -X GET 127.0.0.1/something
What will the parameters values be if not specified in the invocation? (valString=?, valInt=?, valBool=?)
Short answer
The parameter values will be:
valString
:null
valInt
:0
valBool
:false
A bit longer answer
Quoting the Java EE 7 tutorial about extracting request parameters:
The default values for primitive types are described in the Java Tutorials from Oracle:
As you already know, this behavior can be changed by using the
@DefaultValue
annotation as following: