展示出all的数据
<%
// 使用IEmpServiceImpl 的服务接口中的list方法
List<Emp> list = ServiceFactory.getIEmpServiceInstance().list();
%>
<%
Iterator it = list.iterator();
while(it.hasNext()) {
Emp vo = it.next();
<tr>
<td><%=vo.getEmpno()%></td>
<td><%=vo.getEname()%></td>
</tr>
}
%>
// 可以上面的while中打印表格(html+css)
添加信息:
删除信息:
String eno = request.getParameter();
int empno = Integer.parseInt(eno);
int rs = ServiceFactory.getEmpServiceInstance().delete(empno);
if(re==0) {
} else {
}
修改信息:
String eno = request.getParameter();
int empno = Integer.parseInt(eno);
Emp vo = ServiceFactory.getIEmpServiceInstance().updatePre(empno);
// 在上面把我们需要的参数全部找到后 回填到表格中
// value="<%vo.getEname()%>"
更新:
// 获取参数
request.setCharaterEncoding("UTF-8");
getParameter......
// 更新的预操作 是传入id
// 更新的核心操作是 传入对象 去更新
int rs = ServiceFactory.getIEmpServiceInstance().update(emp)
if(rs >0) {
request.setAttribute("msg","修改成功");
}