@RequestMapping("/delete")
public String delete(String id, RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("msg","删除成功!");
return "redirect:index";
}
@RequestMapping({"", "/", "/index"})
public String index( @ModelAttribute("msg") String msg) {
logger.info("index() msg " + msg);
return "bus/busserviceprovider/busServiceProviderIndex";
}
在Index 方法中使用@RequestParam:注解不能获取到重定向传递过来的参数,使用@ModelAttribute可以获取数据。