|
15 | 15 | @Controller |
16 | 16 | public class EmployeeController { |
17 | 17 |
|
18 | | - @RequestMapping(value = "/employee", method = RequestMethod.GET) |
19 | | - public ModelAndView showForm() { |
20 | | - return new ModelAndView("employeeHome", "employee", new Employee()); |
21 | | - } |
| 18 | + @RequestMapping(value = "/employee", method = RequestMethod.GET) |
| 19 | + public ModelAndView showForm() { |
| 20 | + return new ModelAndView("employeeHome", "employee", new Employee()); |
| 21 | + } |
22 | 22 |
|
23 | | - @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) |
24 | | - public String submit(@Valid @ModelAttribute("employee")Employee employee, BindingResult result, |
25 | | - ModelMap model) { |
26 | | - if (result.hasErrors()) { |
27 | | - return "error"; |
28 | | - } |
29 | | - model.addAttribute("name", employee.getName()); |
30 | | - model.addAttribute("contactNumber", employee.getContactNumber()); |
31 | | - model.addAttribute("id", employee.getId()); |
32 | | - return "employeeAdded"; |
33 | | - } |
| 23 | + @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) |
| 24 | + public String submit(@Valid @ModelAttribute("employee") Employee employee, BindingResult result, ModelMap model) { |
| 25 | + if (result.hasErrors()) { |
| 26 | + return "error"; |
| 27 | + } |
| 28 | + model.addAttribute("name", employee.getName()); |
| 29 | + model.addAttribute("contactNumber", employee.getContactNumber()); |
| 30 | + model.addAttribute("id", employee.getId()); |
| 31 | + return "employeeAdded"; |
| 32 | + } |
34 | 33 | } |
0 commit comments