public void init() throws ServletException{
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
studentService = (IStudentService)context.getBean("studentService");
}

本文介绍了一个在Spring框架中使用依赖注入的例子。通过WebApplicationContextUtils获取Web应用上下文,并从上下文中获取名为'studentService'的服务实例。
public void init() throws ServletException{
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
studentService = (IStudentService)context.getBean("studentService");
}

1190
1430

被折叠的 条评论
为什么被折叠?
