/** * Handler method to process URLs ending with /bugs/<id>, that are invoked by HTTP GET methods, * and which have a query parameter named "form". The purpose of this method is to retrieve a form * that users can use to edit the specified bug. * * @param id the id of the bug to edit. * @param uiModel the model supplied by the MVC framework. This method will populate the model * with the required bug so that is can be included in the view. * @return logical view name. */ @RequestMapping(value = "/{id}", params = "form", method = RequestMethod.GET) public String updateForm(@PathVariable("id") Long id, Model uiModel) { // Lookup the bug and add it to the model. uiModel.addAttribute("bug", bugDao.findBugById(id)); return "bug/update"; }
@RequestMapping(value = "/{id}/delete", method = RequestMethod.GET) public String delete( @PathVariable("id") Long id, Model uiModel, RedirectAttributes redirectAttributes) { _logger.info("Process delete"); bugDao.delete(bugDao.findBugById(id)); return "redirect:/bug/"; }
/** * Handler method to process URLs ending with /bugs/<id> and that are invoked by HTTP GET methods. * This method finds a Bug with the specified id and adds it to the model. * * @param id the unique id of the Bug required. * @param uiModel the model that is supplied by the MVC framework and which will be used to store * the bug. * @return logical name of the view to render the model. */ @RequestMapping(value = "/{id}", method = RequestMethod.GET) public String show(@PathVariable("id") Long id, Model uiModel) { _logger.info("Process form GET show"); // Lookup the bug. BugTracking bug = bugDao.findBugById(id); // Add the bug to the model. uiModel.addAttribute("bug", bug); _logger.info("Process form GET show successful"); // Return the logical view name that will render the model. return "bug/show"; }