问题描述
代码如下:@Controller@RequestMapping("/checkerAction.do")public class CheckerAction {@Autowiredprivate CheckerService checkerService;@RequestMapping(params = "method=showAllChecker")public String showAllChecker(ModelMap model){List<checker> checkers = checkerService.listAllChecker();model.addAttribute("checkers",checkers);return "checker";}@RequestMapping(params = "method=deleteChecker")public void deleteChecker(){Checker c = new Checker();c.setCheckerName("test");checkerService.deleteChecker(c);}}现在的问题是执行http://localhost:......./checkerAction.do?method=deleteChecker后想转发到执行showAllCheckers这个action上,要怎么写注解啊问题补充谢谢大家的帮忙!
解决方案
这样应该可以。@RequestMapping(params = "method=deleteChecker")public ModelAndView deleteChecker(){ Checker c = new Checker(); c.setCheckerName("test"); checkerService.deleteChecker(c); ModelAndView mav = new ModelAndView(new RedirectView("checkerAction.do?method=showAllCheckers")); return mav}
解决方案二:
ModelAndView mav = new ModelAndView(new RedirectView("checkerAction.do?method=showAllCheckers"))
解决方案三:
可以通过网页跳转。比如执行完后,在网页上用JSP标签跳转到下一个Action