I have an endpoint which receives a JSON through POST request.
RequestMapping(value = "/app/login", method = RequestMethod.POST,
headers = { "Content-type=application/json" })
@ResponseBody
public LoginResponse logIn(@RequestBody LoginRequest jsonRequest) {
// code
}
LoginRequest:
public class LoginRequest {
private String user;
private String password;
private String idPush;
private Integer idDevice;
// getters and setters
}
Is there anyway I can specify idDevice as optional?
If I don't send idDevice inside the json, Spring returns a 400 error.
@RequestBody SearchParam<T> jsonRequest
. the flagrequired=false
is applied at SearchParam and not the extending class. – Nigercongo