I have an User
object stored in the session with @SessionAttributes
. And a straight-forward method decorated with @ModelAttribute
in o
use @SessionAttribute
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String showItem(@PathVariable("id") Long id, @SessionAttribute("user") User user,
Model uiModel) {
...
}
How about this approach -
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String showItem(@PathVariable("id") Long id,
Model uiModel) {
User user = (User)uiModel.asMap().get("user");
...
}