日期:2014-05-17  浏览次数:20769 次

EL表达式问题?怎么获取对象的属性对象的属性对象的属性?
1、SSH的小虾米不懂是否可以获取对象的属性对象的属性对象的属性?
2、不可以的 话 用ognl表达式可以吗?
求解谢谢大虾。

list.jsp
	<table>
<tbody>
<tr>
<td>序号</td>
<td>工号</td>
<td>姓名</td>
<td>部门</td>
</tr>


<c:forEach items="${liveinfos }" var="liveinfo">
<tr>
<td>${liveinfo.live_id }</td>
<td>${liveinfo.employee.emp_no }</td>
<td>${liveinfo.employee.emp_name }</td>
<td>${liveinfo.employee.department.dep_name }</td>
</tr>

</c:forEach>
</tbody>
</table>

Employee.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cn.model">
<class name="cn.model.Employee" table="employee">
<cache include="all" region="cn.model.Employee" usage="read-write" />

<id type="integer" name="emp_id" column="emp_id">
<generator class="native" />
</id>
<property generated="never" length="200" name="emp_name"
not-null="true" type="string" />
<property generated="never" length="200" name="emp_no" type="string" />
<many-to-one name="depart" column="depart_id"></many-to-one>
</property>
<one-to-one name="liveinfo" />
</class>
</hibernate-mapping>


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cn.model">
 <class name="cn.model.Department" table="department">
  <cache include="all" region="cn.model.Department" usage="read-write"/>

  <id type="integer" name="dep_id" column="dep_id"><generator class="identity" /></id>
  <property generated="never" length="200" name="dep_name" column="dep_name"  type="string"/>
  <property generated="never" length="200" name="dep_shortname" column="dep_shortname"   type="string"/>
  <set name="emp_set" >
   <key column="depart_id"></key>
   <one-to-many class="Employee" />
  </set>
  
  
 </class>
</hibernate-mapping>

action.java
	public String list(){
ActionContext.getContext().put("liveinfos", liveinfoService.list());

return "list"