Example #1
0
 @RequestMapping(value = "/student.do", method = RequestMethod.POST)
 public String doActions(
     @ModelAttribute Student student,
     BindingResult result,
     @RequestParam String action,
     Map<String, Object> map) {
   Student studentResult = new Student();
   switch (action.toLowerCase()) {
     case "add":
       studentService.add(student);
       studentResult = student;
       break;
     case "edit":
       studentService.edit(student);
       studentResult = student;
       break;
     case "delete":
       studentService.delete(student.getStudentId());
       studentResult = new Student();
       break;
     case "search":
       Student searchedStudent = studentService.getStudent(student.getStudentId());
       studentResult = searchedStudent != null ? searchedStudent : new Student();
       break;
   }
   map.put("student", studentResult);
   map.put("studentList", studentService.getAllStudent());
   return "student";
 }
Example #2
0
 @RequestMapping("/index")
 public String setupForm(Map<String, Object> map) {
   Student student = new Student();
   map.put("student", student);
   map.put("studentList", studentService.getAllStudent());
   return "student";
 }