0

After reading related questions, such as:

Spring MVC form handling form multiple pojos

Spring MVC: Having multiple @ModelAttribute in form handling action

I still wonder how could a Spring MVC <form: tag handle multiple modelAttributes. In the answers to the questions above, they either use JSON ( Why?) or use some tricks in the name of the raw input HTML tags. Could somebody post a minimal, working example here ( two Pojos, a Controller and a view)?

Alex Mi
  • 1,409
  • 2
  • 21
  • 35
  • 1
    You can only have a single model attribute. If you want multiple you need to wrap those in another single attribute. Or stop using the form tags, write a regular HTML form and deduct the `name` from the model attributes you want to use. Although you will loose the fact that a form is pre-filled with the values from the model attribute. – M. Deinum Dec 23 '20 at 07:50
  • @M.Deinum could you post this as an answer, please? With a minimal, working example? Thank you! – Alex Mi Dec 23 '20 at 08:06
  • 1
    That is already in one of the questions you refer to. – M. Deinum Dec 23 '20 at 08:13
  • @M.Deinum which one do you mean? I cannot get working neither of them! – Alex Mi Dec 23 '20 at 08:52

0 Answers0