dao中
public List<EmployeeInfo> queryInfo() throws Exception;
dao的实现中
@Override
public List<EmployeeInfo> queryInfo() throws Exception {
return this.getHibernateTemplate().find("from EmployeeInfo ");
}
service中
public List<EmployeeInfo> queryInfo() throws Exception;
service的实现中(BO)
@Resource private EmployeeDao dao;
@Override
public List<EmployeeInfo> queryInfo() throws Exception {
return dao.queryInfo();
}
Action中
public String queryEmpinfo(){
try {
HttpServletRequest request=ServletActionContext.getRequest();
List<EmployeeInfo> selectempinfo= empService.queryInfo();
request.setAttribute("selectempinfo", selectempinfo);
if(selectempinfo!=null){
return "index";
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "myJsp";
}
页面1
<a href="EmployeeAction_queryEmpinfo.action">单击</a><br/>
页面2
<s:iterator value="#request.selectempinfo">
<tr>
<td><s:property value="staffCode"/></td>
<td><s:property value="workDate"/></td>
<td><s:property value="week"/></td>
<td><s:property value="workStart"/></td>
<td><s:property value="workEnd"/></td>
</tr>
</s:iterator>
</table>
ssh? 数据库 jsp 读取数据 显示
<s:iterator value="#request.selectempinfo" var="info">
<tr>
<td><s:property value="info.staffCode"/></td>
<td><s:property value="info.workDate"/></td>
<td><s:property value="info.week"/></td>
<td><s:property value="info.workStart"/></td><s:iterator value="#request.selectempinfo" id="info">
<tr>
<td><s:property value="#info.staffCode"/></td>
<td><s:property value="#info.workDate"/></td>
<td><s:property value="#info.week"/></td>
<td><s:property value="#info.workStart"/></td>
<td><s:property value="#info.workEnd"/></td>
</tr>
</s:iterator>