使用Spring MVC时传递FlashAttribute无法在controller中接收的问题

为了实现一个授权登录的功能,需要在两个controller中跳转,可是中间传递的参数必须要隐密,于是便使用了RedirectAttributes类进行参数的传递。

可是使用的时候发现,无论使用request.getParameter还是getAttribute以及redirectAttributes.getFlashAttributes().get()的方式都不能获取到结果。

查了很多资料后找到了方法:
public Map<String, Object> acceptAuth(HttpServletRequest request, @ModelAttribute("param") String param)
如上,把需要传递的参数放在方法中,并且加上@ModelAttribute(“xxxx”)就能取到值了,完美!

使用Spring MVC时传递FlashAttribute无法在controller中接收的问题

https://www.stonewu.com/post/spring-mvc-flashattr.html

作者

StoneWu

发布于

2017-06-09

更新于

2023-02-14

许可协议

评论