Ejemplo n.º 1
0
  /*
   * This method will be called on form submission, handling POST request for
   * saving employee in database. It also validates the user input
   */
  @RequestMapping(
      value = {"/new"},
      method = RequestMethod.POST)
  public String saveEmployee(@Valid Employee employee, BindingResult result, ModelMap model) {

    if (result.hasErrors()) {
      return "registration";
    }

    service.saveEmployee(employee);

    model.addAttribute("success", "Employee " + employee.getName() + " registered successfully");
    return "success";
  }