jsp新闻发布系统(源码+数据库) 第6页
ManagerFacade.java*****************************/
public class ManagerFacadeImpl implements ManagerFacade {
private ManagerDao managerDao;
public ManagerFacadeImpl() {
this.managerDao = new ManagerDaoImpl();
}
public List managerSelect(ManagerActionForm managerActionForm) {
return this.managerDao.managerSelect(managerActionForm); //利用对象managerDao调用持久层的方法
}
}
控制层实现的代码如下:
/*********************************ManagerFacade.java****************************/
package com.victor.webtier.managerAction;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.victor.domain.ManagerActionForm;
import com.victor.service.ManagerFacade;
import com.victor.service.ManagerFacadeImpl;
import java.io.UnsupportedEncodingException; //加载所需要的类
//总管理员全部查看信息
public class AdminSelectAction extends Action {
private ManagerFacade managerFacade;
public AdminSelectAction() {
this.managerFacade = new ManagerFacadeImpl();
}
public ActionForward perform(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
ManagerActionForm managerActionForm = (ManagerActionForm) actionForm;
managerActionForm.setManagerMark("普通管理员");
httpServletRequest.setAttribute("listAdminSelect",managerFacade.managerSelect(managerActionForm));
return actionMapping.findForward("adminSelectAction");
}
}
struts-config.xml的配置:
/******************************* struts-config.xml*********************************/
<action name="managerActionForm" type="com.victor.webtier.managerAction.AdminSelectAction" validate="true" scope="request" path="/adminSelectAction">
<forward name="adminSelectAction" path="/jsp/managerBack/aManager/adminSelect.jsp" />
</action>
管理员查询jsp代码的实现:
/**********************************adminSelect.jsp*******************************/
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.List"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.victor.domain.ManagerActionForm"%>
<html>
<head>
<title>查看全部信息</title>
</head>
<script Language="JavaScript">
function projectDelete(date){
if(confirm("是否删除这一组数据吗?"))
window.location="adminDeleteAction.do?managerID="+date;
}
</script>
<%List adminList=(List)request.getAttribute("listAdminSelect");%>
<body bgcolor="#ffffc0">
<div align="center" >
<p>查看全部信息</p>
<table width="801" border="2" cellspacing="3" cellpadding="3">
<tr>
<td width="98" height="32">数据库ID</td>
<td width="71">帐号</td>
<td width="96">真实姓名</td>
<td width="94">注册时间</td>
<td width="118">管理员类别</td>
<td width="110">操作</td>
</tr>
<%for(int i=0;i<adminList.size();i++){
ManagerActionForm managerActionForm=(ManagerActionForm)adminList.get(i);
%>
<tr>
<td height="47"><%=managerActionForm.getManagerID()%></td>
<td><%=managerActionForm.getManagerName()%></td>
<td><%=managerActionForm.getManagerRealName()%></td>
<td><%=managerActionForm.getManagerIssueDate()%></td>
<td><%=managerActionForm.getManagerMark()%></td>
<td><a href="adminSelectOneAction.do?ID=<%=managerActionForm.getManagerID()%>">修改</a>
<a href="javascript:projectDelete('<%=managerActionForm.getManagerID()%>')">删除</a></td>
</tr>www.751com.cn
<%}%>
</table><p> </p></div><h1> </h1>
</body>
</html>
通过以上的代码就能够实现对所有的管理员的查询功能。总管理员除了具备查询功能外,还可以修改及删除管理员的信息。
3.修改之前的条件查询操作
在执行修改之前首先是对要修改的数据进行查询。样式层所要调用的类是ActionForm,与用户登录调用的actionForm是同一个类,在这里就不做介绍了,实现的过程如下。
具体在持久层的条件查询代码如下:
接口类的方法的代码:
/**************************** ManagerDao.java ********************************/
public interface ManagerDao {
public List adminSelectOne(ManagerActionForm managerActionForm);
)
实现接口类的方法的代码:
/**************************** ManagerDaoImpl.java *********************************/
//总管理员的单独查找,查找的内容在下一页中显示
public List adminSelectOne(ManagerActionForm managerActionForm) {
ManagerActionForm manager = null;
List list = new ArrayList();
JDBConnection connection = new JDBConnection();
String sql = "select * from tb_manager where ID='" +
managerActionForm.getManagerID() + "'"; //以数据库中的流水号为条件进行查询
ResultSet rs = connection.executeQuery(sql); //执行查询的方法
try {
while (rs.next()) {
manager = new ManagerActionForm();
manager.setManagerID(Integer.valueOf(rs.getString(1)));
manager.setManagerName(rs.getString(2));
manager.setManagerPassword(rs.getString(3));
manager.setManagerRealName(rs.getString(4));
manager.setManagerIssueDate(rs.getString(5));
manager.setManagerMark(rs.getString(6));
list.add(manager);
}
}
catch (SQLException ex) { }
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页
jsp新闻发布系统(源码+数据库) 第6页下载如图片无法显示或论文不完整,请联系qq752018766