@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 }
@RequestMapping("/blog/remove/{id}") public String removeBlog(@PathVariable int id) { Blog blog = blogService.findOne(id); blogService.delete(blog); return "redirect:/account.html"; }