From b9c58d69bce3e7d4d7f304f431328409373bd975 Mon Sep 17 00:00:00 2001 From: RoshanThomas Date: Sun, 13 Mar 2016 20:38:30 -0400 Subject: [PATCH] Removing HTML media type --- .../spring/controller/EmployeeController.java | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/EmployeeController.java b/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/EmployeeController.java index 753f243edb..aa25f47a2a 100644 --- a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/EmployeeController.java +++ b/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/EmployeeController.java @@ -22,35 +22,24 @@ public class EmployeeController { @RequestMapping(value = "/employee", method = RequestMethod.GET) public ModelAndView showForm() { - return new ModelAndView("employeeHome", "employee", new Employee()); + return new ModelAndView("employeeHome", "employee", new Employee()); } @RequestMapping(value = "/employee/{Id}", produces = { "application/json", "application/xml" }, method = RequestMethod.GET) public @ResponseBody Employee getEmployeeById(@PathVariable final long Id) { - return employeeMap.get(Id); - } - - @RequestMapping(value = "/employee/{Id}", method = RequestMethod.GET) - public String getEmployeeByIdHtmlView(@PathVariable final long Id, final ModelMap model) { - model.addAttribute("name", employeeMap.get(Id).getName()); - model.addAttribute("contactNumber", employeeMap.get(Id).getContactNumber()); - model.addAttribute("id", employeeMap.get(Id).getId()); - - return "employeeView"; + return employeeMap.get(Id); } @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) public String submit(@ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) { - if (result.hasErrors()) { - return "error"; - } - model.addAttribute("name", employee.getName()); - model.addAttribute("contactNumber", employee.getContactNumber()); - model.addAttribute("id", employee.getId()); - - employeeMap.put(employee.getId(), employee); - - return "employeeView"; + if (result.hasErrors()) { + return "error"; + } + model.addAttribute("name", employee.getName()); + model.addAttribute("contactNumber", employee.getContactNumber()); + model.addAttribute("id", employee.getId()); + employeeMap.put(employee.getId(), employee); + return "employeeView"; } }