在 Spring MVC 中,我可以使用我的方法连接会话。没关系。
@RequestMapping(value = "/{cid}/read")
public @ResponseBody
boolean markAsRead(@PathVariable("cid") Comment comment, HttpSession session) {
User user = ((User) session.getAttribute("user"));
... }
我可以将上面的用户定义连接到方法定义吗?我的意思是而不是接线会话
@RequestMapping(value = "/{cid}/read")
public @ResponseBody
boolean markAsRead(@PathVariable("cid") Comment comment, User user) {
//No need to inject HttpSession and
//no need to call user = ((User) session.getAttribute("user"));
... }