特别是,这可能吗?
我的基本控制器:
@Controller
public class BaseController {
@ModelAttribute("user")
public User getUser(@PathVariable String id) {
// return User to any models in the child class
}
}
儿童控制器一:
@Controller
public class ChildOneController extends BaseController {
@RequestMapping(value="/user/id/{id}/view", method=RequestMethod.GET)
public ModelAndView updateUserHandler(Model model, @PathVariable String id) {
// Does my model have access to the "user"?
}
}
儿童控制器二:
@Controller
public class ChildTwoController extends BaseController {
@RequestMapping(value="/user/profile/id/{id}/view", method=RequestMethod.GET)
public ModelAndView updateUserHandler(Model model, @PathVariable String id) {
// Does my model have access to the "user"?
}
}
在这种情况下,我只是尝试从模型属性中共享用户,但我还想了解以下内容:
我找不到任何能够深入解决继承问题的好参考文献。我记得在Spring 2.5中看到有关扩展AbstractController的内容,但我相信这是在引入注释之前。