- 主题:[求助]请教一个spring mvc 重定向的问题
利用 redirectAttributes 为重定向后的页面传参,但是在最终的showcustomer.jsp中取不到message的值,怎么办?
ps:由于jsp文件都在WEB-INF/jsp下面,所以不能直接重定向到jsp页面,必须经过中间那步showcustomer的请求
@RequestMapping(value="addcustomer", method=RequestMethod.POST)
public String addCustomer(String customer,RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("message","Added successfully.");
return "redirect:showcustomer";
}
@RequestMapping(value="showcustomer", method=RequestMethod.GET)
public ModelAndView addCustomer() {
ModelAndView mv = new ModelAndView ();
mv.setViewName("customer/showcustomer");
return mv;
}
--
FROM 1.202.152.*
你可以在struts里面完成jsp的补全
【 在 hahalovenini (hahalovenini) 的大作中提到: 】
: 利用 redirectAttributes 为重定向后的页面传参,但是在最终的showcustomer.jsp中取不到message的值,怎么办?
: ps:由于jsp文件都在WEB-INF/jsp下面,所以不能直接重定向到jsp页面,必须经过中间那步showcustomer的请求
: @RequestMapping(value="addcustomer", method=RequestMethod.POST)
: ...................
--
FROM 117.184.104.*
做了这步之后 return "redirect:showcustomer";
浏览器的地址栏应该是不是应该变成 <web_root_url>/showcustomer?message=xxxx
了?
@RequestMapping(value="addcustomer", method=RequestMethod.POST)
public String addCustomer(String customer,RedirectAttributes
redirectAttributes) {
redirectAttributes.addFlashAttribute("message","Added
successfully.");
return "redirect:showcustomer";
}
【 在 hahalovenini (hahalovenini) 的大作中提到: 】
: 利用 redirectAttributes 为重定向后的页面传参,但是在最终的showcustomer.jsp
中取不到message的值,怎么办?
: ps:由于jsp文件都在WEB-INF/jsp下面,所以不能直接重定向到jsp页面,必须经过中
间那步showcustomer的请求
: @RequestMapping(value="addcustomer", method=RequestMethod.POST)
: ...................
--
FROM 183.4.61.*