员工:${emp.empName }<br />
部门:${emp.dept.name }
1、在service层获得数据
2、关闭懒加载
通过员工获得所在部门的名称,则在员工方设置。
<many-to-one name="dept" column="dept_id" class="Dept" lazy="false"></many-to-one>
3、OpenSessionInViewFilter
<filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>
时间: 2024-10-07 00:25:27