@RequestMapping(method = RequestMethod.POST)
 public ModelAndView create(
     @Valid Course course, BindingResult result, RedirectAttributes redirect) {
   if (result.hasErrors()) {
     return new ModelAndView("courses/form", "formErrors", result.getAllErrors());
   }
   course = courseService.save(course);
   redirect.addFlashAttribute("globalMessage", "Curso creado correctamente");
   return new ModelAndView("redirect:/{course.id}", "course.id", course.getId());
 }
 @RequestMapping("{id}")
 public ModelAndView view(@PathVariable("id") Long id) {
   Course course = courseService.findCourse(id);
   return new ModelAndView("courses/view", "course", course);
 }
 @RequestMapping
 public ModelAndView list() {
   Iterable<Course> courses = courseService.getCourses();
   return new ModelAndView("courses/list", "courses", courses);
 }