many commandName for one form in Spring MVC

后端 未结 1 756
慢半拍i
慢半拍i 2021-01-15 03:44

I have a page jsp where i will use many attributes from differents POJO Classes so I need to use two commandName in the form. It\'s possible to user multiple @ModelAttribute

1条回答
  •  走了就别回头了
    2021-01-15 04:25

    It is impossible to have multiple commandName attributes with a springform:form tag.

    (The implementation org.springframework.web.servlet.tags.form.FormTag has only a single field to hold this value).

    The easiest solution (that defently works) would be using a wrapper command objects, that has to fields.

    public class CombinedCommand() {
        Activity activity;
        Etabl etabl;
        //Getter and setter
    }
    

    jsp:

    
    
      ...
      
      ...
      
      ...
    
    

    0 讨论(0)
提交回复
热议问题