dimanche 29 mars 2015

@JsonView doesn't work for me (Spring 4.1.5, Jackson 2.5.1)

I have an Entity with @JsonView annotation:



@JsonView(View.Secure.class)
private String password;


Inside my controller:



@RequestMapping(method = RequestMethod.GET, produces = "application/json")
@JsonView(View.Secure.class)
public ResponseEntity<?> getAllUsers(){
return createUserListResponse();
}


My View class:



public class View {

public static class Secure {}
}


I've expected that response will contain only "password" field, but instead it contains nothing. When i remove annotation @JsonView(View.Secure.class) from Controller - it works as usual and returns all fields. What am i doing wrong? Is it required to add some additional configuration into Spring config?


I used this tutorial: http://ift.tt/11QwK3H


Aucun commentaire:

Enregistrer un commentaire