struts2通过checkbox 删除多条记录
2012-03-16 09:17
387 查看
部分代码删了,***背景的为主题关键测试,经过测试,通过找资料忙了一下午,终于将其弄成功
struts2通过checkbox 删除多条记录(解释就不说了),看不懂的私聊
jsp页面
js代码
?
strust.xml配置
..............
<!-- 删除所选新闻 -->
<action name="delSelectNews" class="cn.swust.action.InfoPublishAction" method="delSelectNews">
<result type="redirect" name="success">showNews</result>
</action>
...................
Action处理
struts2通过checkbox 删除多条记录(解释就不说了),看不懂的私聊
jsp页面
<form name="delForm" id="delForm" method="post" action="<%=basePath%>delSelectNews"> <table id="mainpage" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table id="subtree1" style="DISPLAY: " width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="20"><span class="newfont07">选择:<a href="#" class="right-font08" onclick="selectAll();">全选</a>-<a href="#" class="right-font08" onclick="unselectAll();">反选</a></span> <input name="delselect" type="submit" class="right-button08" value="删除所选新闻" onclick="deleSelect()"/> <input name="Submit2" type="button" class="right-button08" value="新建新闻" onclick="link();"/></td> </tr> <tr> <td height="40" class="font42"><table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03"> <tr> <td height="20" colspan="14" align="center" bgcolor="#EEEEEE"class="tablestyle_title"> 新闻列表 </td> </tr> <tr> <td width="5%" align="center" bgcolor="#EEEEEE">选择</td> <td width="15%" height="20" align="center" bgcolor="#EEEEEE">新闻标题</td> <td width="10%" align="center" bgcolor="#EEEEEE">发布人</td> <td width="15%" align="center" bgcolor="#EEEEEE">发布时间</td> <td width="10%" align="center" bgcolor="#EEEEEE">新闻是否置顶</td> <td width="10%" align="center" bgcolor="#EEEEEE">新闻是否已发布</td> <td width="26%" align="center" bgcolor="#EEEEEE">操作</td> </tr> <s:iterator value="InfoList" var="c"> <tr align="center"><td bgcolor="#FFFFFF"> <input type="checkbox" name="delid" value="${infoId}" /></td> <td height="20" bgcolor="#FFFFFF"><s:property value="#c.infoTitle"/></td> <td bgcolor="#FFFFFF"><s:property value="#c.userPuber"/></td> <td bgcolor="#FFFFFF"><s:property value="#c.infoTime"/></td> <td bgcolor="#FFFFFF"> <s:if test="#c.isTop==1">置顶</s:if> <s:if test="#c.isTop==0">否</s:if> </td> <td bgcolor="#FFFFFF"> <s:if test="#c.infoIsshow==1">已经发布</s:if> <s:if test="#c.infoIsshow==0">存草稿</s:if> </td> <td bgcolor="#FFFFFF"><a href="delOneNews?infoId=${infoId}" onclick="isdel()">删除</a>|<a href="showOneNews?infoId=${infoId}">编辑</a></td> </tr> </s:iterator> </table></td> </table> </form>
js代码
?
..............
<!-- 删除所选新闻 -->
<action name="delSelectNews" class="cn.swust.action.InfoPublishAction" method="delSelectNews">
<result type="redirect" name="success">showNews</result>
</action>
...................
Action处理
package cn.swust.action; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import cn.swust.bean.InfoPublishBean; import cn.swust.service.InfoPublishService; import com.opensymphony.xwork2.ActionSupport; public class InfoPublishAction extends ActionSupport{ /** * */ private static final long serialVersionUID = 1L; private InfoPublishService InfoService = new InfoPublishService(); private InfoPublishBean Info = new InfoPublishBean(); private int infoId;//新闻id;参数传递用 private List<InfoPublishBean> InfoList; private String startTime;//用于按时间段查询 private String endTime; private long[]delid=new long[]{}; public String execute(){ return "error"; } /** * 增加新闻 * @return */ public String addNews() { System.out.println("内容长度"+Info.getInfoContent().length()); Info.setInfoIsshow(1); InfoService.addNews(Info); return SUCCESS; } /** * 显示所有新闻列表 * @return */ public String showAllNews() { InfoList = InfoService.queryNews(); System.out.println("新闻数量"+InfoList.size()); if(InfoList.size()>0) return SUCCESS; else return "error"; } /** * 根据时间段查询 * @return */ public String showNewsByTime() { HttpServletRequest request = ServletActionContext.getRequest(); startTime=request.getParameter("startTime"); endTime = request.getParameter("endTime"); System.out.println("开始时间 "+startTime+" 结束时间 "+endTime); InfoList = InfoService.queryNewsByTime(startTime, endTime); System.out.println("新闻数量"+InfoList.size()); if(InfoList.size()>0) return SUCCESS; else return "error"; } /** * 删除一条新闻 * @return */ public String delOneNews() { System.out.println(infoId); InfoService.delNews(infoId); return SUCCESS; } /** * 删除所选新闻 * @return */ public String delSelectNews() { System.out.println("所选新闻"); for(int i=0;i<this.delid.length;i++) InfoService.delNews((int)delid[i]); return SUCCESS; } /** * 显示一条新闻列表 * @return */ public String showOneNews() { Info = InfoService.queryOneNews(infoId); return SUCCESS; } /** * 修改一条新闻 * @return */ public String updateNews() { Info.setInfoId(infoId); Info.setInfoIsshow(1); InfoService.updateNews(Info); return SUCCESS; } public InfoPublishService getInfoService() { return InfoService; } public void setInfoService(InfoPublishService infoService) { InfoService = infoService; } public InfoPublishBean getInfo() { return Info; } public void setInfo(InfoPublishBean info) { Info = info; } public List<InfoPublishBean> getInfoList() { return InfoList; } public void setInfoList(List<InfoPublishBean> infoList) { InfoList = infoList; } public int getInfoId() { return infoId; } public void setInfoId(int infoId) { this.infoId = infoId; } public String getStartTime() { return startTime; } public void setStartTime(String startTime) { this.startTime = startTime; } public String getEndTime() { return endTime; } public void setEndTime(String endTime) { this.endTime = endTime; } public long[] getDelid() { return delid; } public void setDelid(long[] delid) { this.delid = delid; } }
相关文章推荐
- 用checkbox一次性删除多条记录
- php 通过CheckBox删除选中记录
- 通过存储过程进行字符串分拆,在同时删除多条记录的时候有用。
- SQL存储过程通过传送数组字符串参数删除多条记录
- WinForm中DataGridView控件通过复选框实现多条记录的删除 c#2005
- php 用checkbox一次性删除多条记录的方法
- php 用checkbox一次性删除多条记录的方法
- php 用checkbox一次性删除多条记录的方法
- 删除msconfig里的启动记录(通过注册表实现)
- ASP.NET 同时删除多条记录
- 通过checkbox选择以逗号拼接删除字符串
- mysql批量删除多条记录的sql语句
- zabbix通过jmx监控tomcat, Nginx日志统计方案全过程,切割nginx和tomcat日志并删除指定天数前的日志记录
- DataTable删除多条记录
- 连表删除多条记录
- SQL语句使用Left Outer join代替In删除多条记录
- ASP.NET2.0下含有CheckBox的GridView删除选定记录实例
- 记录, struts2 checkboxlist 的一个问题
- Domino 9下通过程序删除并记录未知用户及邮件组
- hibernate批量删除多条记录