Adding an attribute to a ModelAndView

后端 未结 1 1872
天涯浪人
天涯浪人 2021-01-18 05:54

I\'m writing a HandlerInterceptor that needs to insert a certain session-scoped bean into the Model. postHandle\'s signature looks lik

相关标签:
1条回答
  • 2021-01-18 06:51

    Use modelAndView.addObject("key", value)

    There are also some other indirect ways, through modelAndView.getModel() or modelAndView.getModelMap(). But you should prefer the addObject(..) version. In fact it invokes getModelMap().addAttribute(..)

    0 讨论(0)
提交回复
热议问题