struts中如何在后台控制器实现前台的带有checkbox的删除操作,下面代码中省略号部分该如何操作?
AgreementAction.javapublicActionForwarddoDeleteAll(ActionMappingmapping,ActionFormfor...
AgreementAction.java
public ActionForward doDeleteAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 获取请求参数
……
// 参数校验后业务处理
……
// 返回列表页面
try {
response.sendRedirect("/SNTAXAPP/agreement.do?op=toShowAgreementList");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
agreementList.jsp:
<html:form action="/agreement.do?op=toShowAgreementList" method="post">
<table width="98%" align="center" class="border" id="mytable" border="1" style="padding: 0px">
<thead>
<tr>
<th><input type="checkbox" onclick="clickme(this)"/></th>
<th>序号</th>
<th>申请单号</th>
<th>协议编号</th>
<th>商品总类名称</th>
<th>供应商名称</th>
<th>供应商税号</th>
<th>数量</th>
<th>金额</th>
<th>税额</th>
<th>类型</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach var="item" items="${agreementForm.pageBean.dataList}">
<tr>
<td><input type="checkbox" value="${item.agreementNo }" name="agreementNo"/></td>
<td>${item.id }</td>
<td>${item.number }</td>
<td>${item.agreementNo }</td>
<td>${item.goodsName }</td>
<td>${item.sellNameFormat }</td>
<td>${item.sellTaxNo }</td>
<td>${item.amount }</td>
<td>${item.total }</td>
<td>${item.tax }</td>
<td>${item.type }</td>
<td>
<html:link action="/agreement.do?op=toShowAgreementDetail&agreementNo=${item.agreementNo}" target="_bank">详细</html:link>
|
<html:link action="/agreement.do?op=doDelete&id=${item.id}" onclick="return isDel()">删除</html:link>
</td>
</tr>
</c:forEach>
<tr>
<td colspan="12">
<kevin:page formName="agreementForm" />
</td>
</tr>
</tbody>
</table>
</html:form> 展开
public ActionForward doDeleteAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 获取请求参数
……
// 参数校验后业务处理
……
// 返回列表页面
try {
response.sendRedirect("/SNTAXAPP/agreement.do?op=toShowAgreementList");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
agreementList.jsp:
<html:form action="/agreement.do?op=toShowAgreementList" method="post">
<table width="98%" align="center" class="border" id="mytable" border="1" style="padding: 0px">
<thead>
<tr>
<th><input type="checkbox" onclick="clickme(this)"/></th>
<th>序号</th>
<th>申请单号</th>
<th>协议编号</th>
<th>商品总类名称</th>
<th>供应商名称</th>
<th>供应商税号</th>
<th>数量</th>
<th>金额</th>
<th>税额</th>
<th>类型</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach var="item" items="${agreementForm.pageBean.dataList}">
<tr>
<td><input type="checkbox" value="${item.agreementNo }" name="agreementNo"/></td>
<td>${item.id }</td>
<td>${item.number }</td>
<td>${item.agreementNo }</td>
<td>${item.goodsName }</td>
<td>${item.sellNameFormat }</td>
<td>${item.sellTaxNo }</td>
<td>${item.amount }</td>
<td>${item.total }</td>
<td>${item.tax }</td>
<td>${item.type }</td>
<td>
<html:link action="/agreement.do?op=toShowAgreementDetail&agreementNo=${item.agreementNo}" target="_bank">详细</html:link>
|
<html:link action="/agreement.do?op=doDelete&id=${item.id}" onclick="return isDel()">删除</html:link>
</td>
</tr>
</c:forEach>
<tr>
<td colspan="12">
<kevin:page formName="agreementForm" />
</td>
</tr>
</tbody>
</table>
</html:form> 展开
2个回答
展开全部
用Form里面定义一个集合接受checkbox得参数。,然后根据集合删除
for(...;...;...;){
delete(id);
}
for(...;...;...;){
delete(id);
}
更多追问追答
追问
AgreementForm agreementForm = (AgreementForm) form;
这个form怎么来接收?能再详细点吗?谢谢!!!
追答
比如说再jsp页面中有checkbox得名字是check 你就再actionform中定义一个check[]来接收,
然后只要再 ,
for(int i=0;i< agreementForm .check.length;i++s){
//根据你接收到得值来删除 delete(agreementForm .check[i]);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询