Iam getting null parameter values when i send values from rest client. But when I send Values from form(html view page) it is working fine.
Below one is my bean class.
public class Home {
private String id;
@NumberFormat
private int customerId;
@NotEmpty
private String Code;
@NotEmpty
private String load;
public String getId() {
return Id;
}
public void setId(String Id) {
this.Id = Id;
}
public int getCustomerId() {
return customerId;
}
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLoad() {
return load;
}
public void setLoad(String load) {
this.load = load;
}
}
And this is my controller class.
@RequestMapping(value = "/home", method = RequestMethod.POST, consumes = {"application/json", "application/x-www-form-urlencoded"},
produces = "application/json")
public String getCustomerMessageResponse(@ModelAttribute Home homeRequest,
HttpServletRequest request) {
System.out.println("homeRequest.id()--------------"+homeRequest.getId());
System.out.println("homeRequest.getCustomerId()--------------"+homeRequest.getCustomerId());
System.out.println("homeRequest.getCode()-------------"+homeRequest.getCode());
System.out.println("homeRequest.getLoad()--------------"+homeRequest.getLoad());
And I am sending values from rest client as post method.
{
"id":"10",
"customerId":1,
"code":"FRD2WY",
"load":"true"
}
Content-Type: application/json
Request is coming to the controller class. but it will return all values as null .But when I am sending values from html page it is working fine. Any one can help how to get values.
Aucun commentaire:
Enregistrer un commentaire