コード例 #1
0
 @RequestMapping(value = "/account", method = RequestMethod.POST)
 public String doAddBlog(
     Model model,
     @Valid @ModelAttribute("blog") Blog blog,
     Principal principal,
     BindingResult result) {
   if (result.hasErrors()) {
     return account(model, principal);
   }
   String name = principal.getName();
   blogService.save(blog, name);
   return "redirect:/account.html"; // here we dont have to show ?success=true because the new blog
                                    // will be visible on the page
 }
コード例 #2
0
 @RequestMapping("/blog/remove/{id}")
 public String removeBlog(@PathVariable int id) {
   Blog blog = blogService.findOne(id);
   blogService.delete(blog);
   return "redirect:/account.html";
 }