struts <bean:write/>标签疑问?
麻烦大家帮个忙!
怎么输出struts中标签<bean:write>中属性是对象的值啊
<logic:iterate id="employee" name="employeeList" type="cn.dyp.traver.model.Employee" scope="request">
<tr>
<td><bean:write name="employee" property="ename"/></td>
<td><bean:write name="employee" property="esex"/></td>
<td><bean:write name="employee" property="ecard"/></td>
<td><bean:write name="employee" property="ephone"/></td>
<td><bean:write name="employee" property="ejob"/></td>
<td><bean:write name="employee" property="ecertificate"/></td>
<td><bean:write name="employee" property="eitime"/></td>
<td><bean:write name="employee" property="eaddress"/></td>
<td><bean:write name="employee" property="eremark"/></td>
<td><bean:write name="employee" property="TDept"/></td>
</logic:iterate>
比如我想输出TDept对象中的name属性值?
------解决方案--------------------
我在接个话吧~~~
但凡框架底层都是注入方法的~~
没办法,人家反射机制就那么定义的;
get,set,方法是必然的,面向对象的思想为非就是封装,继承,多态;
写个简单的底层封装吧~~~
public void testIoc() throws Exception {
String path = "com.wang.pojo.User";
//相当于在struts的xml配的form;
Class voClass= Class.forName(path);
Object vo= voClass.newInstance();
String voId = "name";
String pas = voId.substring(0, 1).toUpperCase()+voId.substring(1,voId.length());
voId = "set"+pas;
Method m= voClass.getMethod(voId, new Class[]{String.class});
m.invoke(vo,new String[]{"王哲涵"});
//测试
User u= (User) vo;
System.out.print(u.getName());
}
大略就这样,为了20分,我容易吗我~~泪水啊