users@jersey.java.net

Is it possible to consume FORM_URLENCODED and XML in same method?

From: Bo Xu <bo.xu_at_kibboko.com>
Date: Fri, 25 Jun 2010 10:01:40 -0400

For xml and json I know I can do this:
   @POST
     @Consumes({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
     @Produces("text/plain")
     public String post(Contact c)
     {

         return "got it";
     }

@XmlRootElement(name="contact")
@XmlAccessorType(XmlAccessType.FIELD)
public class Contact {
    .......
}

For FORM_URLENCODED, I have to do it in another way:
@POST
@Consumes({MediaType.APPLICATION_ FORM_URLENCODED})
  public String post(@FormParam("identity_value") String identity,
             @FormParam("identity_type") String type,
             @FormParam("comment") String comment)
{

}


how can I combine them together in one method? Otherwise I have to
create 2 resource classes and each contains a post method?

Thanks!