怎么用SSH从数据库读出一条数据显示在JSp页面,要完整代码。。
2个回答
展开全部
你不会是要整套流程吧。
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的实现中
@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>
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的实现中
@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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询