java - Spring MVC + AngularJS - Adding multiple entries to the data base -



i'm working on "absence management" web app using angularjs , spring mvc.
in jsp, used angularjs retrieve specific students.
want select absent students , add, each 1 of them, absence instance in db.
have 2 classes : student.java, absence.java.

@entity @table(name = "student") public class student {     @id     @generatedvalue(strategy = generationtype.identity)     @column(name = "id_student")     private long idstudent;      @column(name = "name")     private string name;      @onetomany(cascade = cascadetype.all)     @joincolumn(name = "idstudent")     private list<absence> absences = new arraylist<absence>();      //getters & setters... }  @entity @table(name = "absence") public class absence {     @id     @generatedvalue(strategy = generationtype.identity)     @column(name = "id_absence")     private long idabsence;      @column(name = "absence_date")     private date absencedate;      //getters & setters... } 

here jsp :

<form method="post" action="/absences/add">     <table>         <thead>             <tr>                 <th>#</th>                 <th>student</th>             </tr>         </thead>         <tbody>             <tr ng-repeat="student in students">                 <td>                     <input type="checkbox" name="studentsids[]" value="{{student.idstudent}}" />                 </td>                 <td>{{student.name}}</td>             </tr>         </tbody>     </table>     <input type="date" name="absencedate" />      <input type="submit" value="submit"/> </form> 

i searched online , tried multiple stuff nothing seems work.
thank in advance!

edit 1:
tried in controller, i'm having rough time trying add multiple absences ...

@requestmapping(value = "/absences/add", method = requestmethod.post) public string addabsence(@requestparam(studentsids[]) long [] studentsids, absence[] absences) {     //it seems there problem "absence[] absences" ...     return "listabsences"; } 


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -