1

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

Mike Dunker
  • 1,950
  • 15
  • 17
Siva
  • 3,297
  • 7
  • 29
  • 35
  • I'm puzzled by the tags you chose (`web services`, `rest`, `soap`, `restful-architecture`). Isn't your annotations coming from `jax-rs`? If yes, how could it be tagged with `soap`? For reference, which [implementation of jax-rs](http://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services#Implementations) do you use? – Aurélien Bénel Apr 02 '14 at 08:12
  • All tags are related to web services only..! any way i am using jersey. – Siva Apr 02 '14 at 15:30

1 Answers1

0

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?

Community
  • 1
  • 1
jkovacs
  • 3,470
  • 1
  • 23
  • 24
  • Perfect thanks man! I saw different form param annotations but @BeanParam is really awesome! and thanks for the ref. links as well. – Siva Apr 06 '14 at 05:12