课时12:Servlet容器与SpringIoC容器,及二者之间的桥梁

.1)Servlet容器与SpringIoC容器,及二者之间的桥梁

  1.如何打通两个直接的桥梁 解决null指针的问题

    1.1 通过servlet中的init方法来建立连接 原有的在application-Controller.xml--》bean中注入可以删除了

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

    1.2 在实际项目中不会这么写 Struts1.0 Struts2 springMvC会自动整合

原文地址:https://www.cnblogs.com/thisHBZ/p/12512067.html