We can retrieve input params using different type of annotations like... @PathParam,@FormParam ..etc.
and in code,
public Customer getDetails(@FormParam("custNo") int no) {
But what if i have 10+ values in the input form ? is there any other way ? I have searched in Google but all the time i am seeing @PathParams and @FormParams. Can we bind all input form values into some object and retrieve ?
Thank you Siva
Yes, starting with Jersey 2.0 you can use the @BeanParam
annotation to wrap a bunch of parameters in a Java bean. Example:
public class CustomerDetails {
@FormParam("custNo")
public int customerNumber;
@FormParam("whatevs")
public String whatever;
}
public Customer getDetails(@BeanParam CustomerDetails customer) {
// ...
}
Documentation: https://jersey.java.net/apidocs/2.6/jersey/javax/ws/rs/BeanParam.html
Related question: How do you map multiple query parameters to the fields of a bean on Jersey GET request?