Spring MVC的一点疑问
我有一个Controller里的多个方法都需要一个model,能否能添加全局model之类。而不是每个方法里都添加
--------------------编程问答--------------------
@Controller
@RequestMapping("/user")
@SessionAttributes(“user”) //把共享的对象放在session中
public class UserController {
@ModelAttribute("user")
public User getUser(){
User user = new User();
return user;
}
@RequestMapping(value = "/handle71")
public String handle71(@ModelAttribute(“user”) User user){
...
}
@RequestMapping(value = "/handle72")
public String handle72(ModelMap modelMap,SessionStatus sessionStatus){
User user = (User)modelMap.get(“user”);
}
}
补充:Java , 非技术区