我做了一个基于Web的远程教学网站,框架使用的是Struts+hibernate想请教下如何在管理员模块实现用户删除这个功能。下面是页面,应该如何实现。实现的话需要在struts和hibernate下如何进行配置
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'studentlist.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  <style>
p{font-size:35px;
  font-family:黑体;
  color:red;
  text-align:center;
}
span{
color:#ffba00;
font-size:17px;
font-weight:normal;
font-family:楷体_GB2312;

}
</style>
<base href="<%=basePath%>">
</head>
   
  <body leftMargin=0 topMargin=0 marginwidth="500">
&nbsp;&nbsp;
<p>
学生用户&nbsp;&nbsp;
<font color="#FF0000"></font> </p>
<hr align="center" color="blue" size="16">
<table class="datalist" summary="list of members in EE Studay"
align="center" width="800">
<tr>
<th align=center nowrap>
学号
</th>
<th align=center nowrap>
登陆名称
</th>
<th align=center nowrap>
真实姓名
</th>
<th align=center nowrap>
性别
</th> <th align=center nowrap>
申请日期
</th>
<th align=center>
操&nbsp;&nbsp;作
</th>
</tr>
<c:forEach items="${stu.list}" var="appuser">
<tr id="tr"> <td>
${appuser.x_no}
</td>
<td>
${appuser.x_name}
</td>
<td>
${appuser.x_relname}
</td>
<td>
${appuser.x_xb}
</td>
<td>
${appuser.x_date}
</td>
<td align="center" nowrap>
<a href="sys.do?command=delspstu&x_no=${appuser.x_no}">删除</a>
</tr>
</c:forEach>
<tr bgcolor="red"> </tr>
</table>
<hr align="center" color="blue" size="1">
<h3 align="center">
  当前第${stu.pageNo}页
      
                        <c:if test="${1 lt stu.pageNo }"> 
                            <a href="teacher.do?command=mystu_before&pageNo=${stu.pageNo}&pageSize=${stu.pageSize}&fac=1">上一页</a>
                        </c:if>
                            
                        <c:if test="${stu.pageNo lt ((stu.totalRecords/stu.pageSize))}">
                          <a href="sec_card2.do?command=mystu_next&pageNo=${stu.pageNo}&pageSize=${stu.pageSize}&fac=1">下一页</a>
                        </c:if>
                        总共 ${stu.totalRecords}条记录   <span>输入查询条件&nbsp;&nbsp;<input type="text" name="query"></span>
                          </h3><script language="javascript">
var rows = document.getElementsByTagName('tr');
for (var i=0;i<rows.length;i++){
rows[i].onmouseover = function(){ //鼠标在行上面的时候
this.className += 'altrow';
}
rows[i].onmouseout = function(){ //鼠标离开时
this.className = this.className.replace('altrow','');
}
}
</script>
</body>
</html>

解决方案 »

  1.   

    起码你必须建立你的admin和user的pojo类和映射文件吧。然后通过在hibernate.hbm.xml文件中加入你的映射类,还有就是在dao层实现你的crud功能。
      

  2.   

    建议你在实现业务逻辑时用下HibernateDaoSupport类...这样crud很简单
      

  3.   

    首先为管理员表编写hibernate的映射文件,然后增加一个CRUD接口并实现这个接口,如果你用MyEclipse的话这些都可以自动生成。然后定义一个action来接受客户端的请求并向客户端返回json格式的数据,在spring的配置文件里把刚才的接口注入到action里面。请求页面通过ajax发送删除请求到先前定义的action,页面端可以采用extjs或者jquery等一些js框架来提高开发效率。通过js接收服务端返回的数据并显示给最终用户
      

  4.   

    为用户准备一个数据操作方法  delete(Integer uid) 传入唯一键值   当然在此操作之前  LZ 你还要判断 是否为管理员在操作数据祝你好运
      

  5.   

    用hibernate模板,很方便的!  LZ 去试试吧
      

  6.   

    LZ可以试试用hibernate模板技术,里面的可以用delete(Integer uid).