How to pass model attributes from one Spring MVC controller to another controller?

后端 未结 10 1360
暗喜
暗喜 2020-11-27 13:19

I am redirecting from a controller to another controller. But I also need to pass model attributes to the second controller.

I don\'t want to put the model in sessi

10条回答
  •  天命终不由人
    2020-11-27 14:02

    I had same problem.

    With RedirectAttributes after refreshing page, my model attributes from first controller have been lost. I was thinking that is a bug, but then i found solution. In first controller I add attributes in ModelMap and do this instead of "redirect":

    return "forward:/nameOfView";

    This will redirect to your another controller and also keep model attributes from first one.

    I hope this is what are you looking for. Sorry for my English

提交回复
热议问题