java - Spring MVC multiple rows form submit submits new ModelAttribute -
ok 1 of spring's null modelattribute i've tried found doesn't work.
i've adding tutorials functionality web app spring-mvc everythings workds greate except when have data form bean.
i use 2 post methods
@requestmapping(method = requestmethod.post) public string openedit(@requestparam("notfound") string[] notfound, model model){ editform editform = editmodel.createeditform(notfound); model.addattribute("editform",editform); return "edit/editowners"; } @requestmapping(method = requestmethod.post,value = "/saveowners") public string saveowners(@modelattribute("editform") editform editform){ editmodel.addowners(editform); return "index"; }
the first 1 works fine , can see data in jsp, second 1 gets new modelattribute.
this form
<form:form method="post" action="saveowners" modelattribute="editform" > <table class="table table-bordered table-striped table-hover table-condensed"> <caption> <h4>edit owners</h4> </caption> <thead> <tr> <td>name</td> </tr> </thead> <tbody> <c:foreach items="${editform.owners}" var="item" varstatus="status"> <tr> <td>${item.name}</td> <td><input type="text" name="${owners[status.index].outid}" value="${item.outid}" /> </td> <td><input type="text" name="${owners[status.index].type}" value="${item.type}" /> </td> </tr> </c:foreach> </tbody> </table> <input type="submit" value="save" class="btn btn-primary"/> </form:form>
what seems wrong here ? ps tried inputs , without type attribute , still gets null, , said can see data can't submit them.
have tried adding following annotation top of controller class ?
@sessionattributes({ "editform" }) public class yourcontroller { ... }
Comments
Post a Comment