spring 页面跳转

时间:2023-03-09 09:42:49
spring 页面跳转

RedirectAttributes  的两个方式的获取总结:
1:addFlashAttribute

@RequestMapping(value="hello")
public String test(RedirectAttributes ra){
ra.addFlashAttribute("test", "test");
return "redirect:/hello";
}
@RequestMapping(value="test")
public String test(@ModelAttribute("test") String test){
System.out.println(test);
return "redirect:/hello";
}

2:addAttribute

@RequestMapping(value="hello")
public String test(RedirectAttributes ra){
ra.addAttribute("test", "test");
return "redirect:/hello";
}
@RequestMapping(value="test")
public String test(HttpServletRequest request
/* ①:@ModelAttribute("test") String test*/
/*②:@RequestParam("test") String test*/){
/*③:*/String test = request.getParameter("test"); System.out.println(test);
return "redirect:/hello";
}

1