Values of @PathVariable and @ModelAttribute overlapping

后端 未结 2 1689
北海茫月
北海茫月 2021-01-11 18:03

I have an User object stored in the session with @SessionAttributes. And a straight-forward method decorated with @ModelAttribute in o

2条回答
  •  心在旅途
    2021-01-11 18:52

    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");
       ...    
    }
    

提交回复
热议问题