这是一个一劳永逸解决懒加载问题的办法.使用spring的openSessionInViewFilter. openSessionInViewFilter,改过滤器在view渲染时始终开启session,一劳永逸解决hibernate的懒加载问题, 该过滤器必须配置在struts2过滤器之前,如果访问增大性能会降低不推荐使用(性能问题) 第三种: 3.强行在service层面是初始化代理对象. 就是在获取对象之后,强行去加载对象中属性集合(推荐) 例如: public Department getDepartmentWithChildren(Integer id){ Department s = DepartmentDao.getEntity(id); //强行初始化pages和questions集合 for(Student stu : s.getStudents()){ stu.getClasses.size(); } return s; }