diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ContentManagementWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ContentManagementWebConfig.java index 6fd68394ea..31e223260e 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ContentManagementWebConfig.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ContentManagementWebConfig.java @@ -15,39 +15,38 @@ import org.springframework.web.servlet.view.JstlView; @Configuration public class ContentManagementWebConfig extends WebMvcConfigurerAdapter { - public ContentManagementWebConfig() { - super(); - } + public ContentManagementWebConfig() { + super(); + } - // API + // API - @Override - public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { - configurer.favorPathExtension(true). - favorParameter(false). - parameterName("mediaType"). - ignoreAcceptHeader(true). - useJaf(false). - defaultContentType(MediaType.TEXT_HTML). - mediaType("xml", MediaType.APPLICATION_XML). - mediaType("html", MediaType.TEXT_HTML). - mediaType("json", MediaType.APPLICATION_JSON); - } + @Override + public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { + configurer.favorPathExtension(false). + favorParameter(true). + parameterName("mediaType"). + ignoreAcceptHeader(true). + useJaf(false). + defaultContentType(MediaType.APPLICATION_JSON). + mediaType("xml", MediaType.APPLICATION_XML). + mediaType("json", MediaType.APPLICATION_JSON); + } - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + registry.addViewController("/sample.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - bean.setOrder(0); - return bean; - } + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + bean.setOrder(0); + return bean; + } } diff --git a/spring-mvc-java/src/main/java/org/baeldung/web/controller/EmployeeController.java b/spring-mvc-java/src/main/java/org/baeldung/web/controller/EmployeeController.java index 8a41718b8c..e18bbdbf63 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/web/controller/EmployeeController.java +++ b/spring-mvc-java/src/main/java/org/baeldung/web/controller/EmployeeController.java @@ -29,15 +29,6 @@ public class EmployeeController { 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"; - } - @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) public String submit(@ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) { if (result.hasErrors()) { 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..eb069ebf0a 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 @@ -30,15 +30,6 @@ public class EmployeeController { 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"; - } - @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) public String submit(@ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) { if (result.hasErrors()) { diff --git a/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml b/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml index 0fcd85e399..49a5e7c35d 100644 --- a/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml +++ b/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml @@ -23,16 +23,15 @@ - - + + - + -