Skip navigation

this is my pojo

 

@BadgerFish

public class User{

private Stirng name;

private int loginCount = 0;

 

public String getName() {

        return name;

    }

public void setName(String nm) {

        this.name= nm;

    }

public int getLoginCount() {

        return loginCount;

    }

public void setLoginCount(int loginCount) {

        this.loginCount = loginCount;

    } 

}

 

my rest method

 

@POST

    @Path("/user")

    @Consumes(MediaType.APPLICATION_JSON)

    @Produces(MediaType.APPLICATION_JSON)

    public Response postUser(@BadgerFish User user) {    

 

 

        System.out.println("post req.....");

        return Response.status(200).entity("sucess"+p.getLoginCount()).build();

    }

 

 

poblem is

 

JSON Data comes in POST Request:

Case 1: if JSON is -> {"name":"abc"} Response will be 0 (Works as expected)

Case 2: if JSON is -> {"name":"abc","loginCount":"12"}. It should not set the value of loginCount in POJO obj. and Response should be 0.

Filter Blog