java - how to write rest service using @beanparam and @Get mthod -


please me write rest webservice using below class , @beanparam , @get method

 @queryparam("prop1")   public string prop1;   @queryparam("prop2")   public string prop2;   @queryparam("prop3")   public string prop3;   @queryparam("prop4")   public string prop4; 

with pojo this:

public class mybean {      @queryparam("prop1")      private string prop1;      @queryparam("prop2")      private string prop2;      @queryparam("prop3")      private string prop3;      @queryparam("prop4")      private string prop4;      // getters , setters omitted } 

your resource method like:

@get @path("/foo") public response foo(@beanparam mybean mybean) {     ... } 

update: mentioned in comments, return mybean marshaled xml in http response payload, have following:

@get @path("/foo") @produces(mediatype.application_xml) public response foo(@beanparam mybean mybean) {     return response.ok(mybean).build(); } 

ensure have xml provider in dependecies. otherwise, have error like:

javax.ws.rs.processingexception: not find writer content-type application/xml 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -