coure2011
coure2011

Reputation: 42474

DataForm posting values but on server its null

using the DataForm object I found that its posting values correctly to server. Here is the screenshot enter image description here

but on server I am getting null for these object. Here is my server side code

    @RequestMapping(method = POST, value = "/create", produces = "application/json")
    @ResponseBody
    public UIResponse createDS(@Validated @ModelAttribute(value = "dS") DSDto dSDto,
            BindingResult result) {
 //here dSDto.name and dSDto.description is null
}

Upvotes: 0

Views: 113

Answers (1)

Robert Ellis
Robert Ellis

Reputation: 734

you have to add the @RequestBody annotation so Spring would convert the incoming JSON to a object from the post body .take a look at this stack overflow post @RequestBody and @ResponseBody annotations in Spring

Upvotes: 1

Related Questions