Using @Consume with GET request in Jersey Rest

后端 未结 5 645
夕颜
夕颜 2021-02-10 16:05

I\'m trying to bind values in a GET request to a POJO.

The values are parameters in a HTTP GET request. I\'m using JSONP to pass the parameters however it looks like JS

5条回答
  •  别那么骄傲
    2021-02-10 16:54

    As we know GET request cannot consume any entity, we need to pass each parameter as params. To be simple we can do like the below using javax.ws.rs.BeanParam (We can use the @BeanParam instead of @InjectParam

    public JSONWithPadding doSomething(@BeanParam final MyPojo argPojo) 
    

    ....

    public class MyPojo 
    {
    /** */
    @QueryParam("value1")
    private String value1;
    
    /** */
    @QueryParam("value2")
    private String value2;
    
    /** */
    @QueryParam("value3")
    private List value3;
    

提交回复
热议问题