Ask Your Question
4

Can the Map object of a wrapper DTO be converted with POST : @ModelAttribute?

asked 2023-07-07 17:33:41 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-07 17:34:02 +0000

nofretete gravatar image

No, the Map object of a wrapper DTO cannot be converted with POST: @ModelAttribute.

The @ModelAttribute annotation is used to bind the incoming HTTP request to a Java object. However, @ModelAttribute only supports binding of simple Java bean properties and cannot directly bind wrapper classes like Map.

To bind the Map object of a wrapper DTO, one can use @RequestBody annotation and pass the JSON data in the request body as a string. In the controller, the JSON data can be deserialized into the Map object using a JSON parsing library like Jackson or Gson.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-07 17:33:41 +0000

Seen: 10 times

Last updated: Jul 07 '23