jsp向action传值问题
前台jsp代码:functiondeleteCompany(){varids=document.getElementsByTagName("input");varresu...
前台jsp代码:
function deleteCompany() {
var ids =document.getElementsByTagName("input");
var result = "";
if (typeof (ids) != "undefined") {
if (typeof (ids.length) != "undefined") {
for ( var i = 0; i < ids.length; i++) {
if (ids[i].checked) {
result += ids[i].value + ";"
}
}
result = result.substring(0, result.length - 1);
} else {
if(ids.checked)
result = ids.value;
}
}
if (result == "") {
alert("请选择要删除的记录");
} else {
window.location.href = "<%=path %>/docDel.action?ids="+result+"&&groupType=${groupType}";
alert(result);
}
}
后台action代码:
public String docDel() {
String ids=request.getParameter("ids");
System.out.println(ids);
if (ids.indexOf(";") > 0) {
String[] idArray = ids.split(";");
System.out.println(idArray[1]);
for (String id:idArray) {
int id1 = Integer.parseInt(id);
TDoc doc=docDAO.findById(id1);
doc.setDel("yes");
docDAO.attachDirty(doc);
this.setMessage("删除成功");
this.setPath("docMana.action");
}
} else {
TDoc doc=docDAO.findById(id);
doc.setDel("yes");
docDAO.attachDirty(doc);
this.setMessage("删除成功");
this.setPath("docMana.action");
}
return "succeed";
}
我想问下怎么把前台的ids数组传到后台action中,多谢! 展开
function deleteCompany() {
var ids =document.getElementsByTagName("input");
var result = "";
if (typeof (ids) != "undefined") {
if (typeof (ids.length) != "undefined") {
for ( var i = 0; i < ids.length; i++) {
if (ids[i].checked) {
result += ids[i].value + ";"
}
}
result = result.substring(0, result.length - 1);
} else {
if(ids.checked)
result = ids.value;
}
}
if (result == "") {
alert("请选择要删除的记录");
} else {
window.location.href = "<%=path %>/docDel.action?ids="+result+"&&groupType=${groupType}";
alert(result);
}
}
后台action代码:
public String docDel() {
String ids=request.getParameter("ids");
System.out.println(ids);
if (ids.indexOf(";") > 0) {
String[] idArray = ids.split(";");
System.out.println(idArray[1]);
for (String id:idArray) {
int id1 = Integer.parseInt(id);
TDoc doc=docDAO.findById(id1);
doc.setDel("yes");
docDAO.attachDirty(doc);
this.setMessage("删除成功");
this.setPath("docMana.action");
}
} else {
TDoc doc=docDAO.findById(id);
doc.setDel("yes");
docDAO.attachDirty(doc);
this.setMessage("删除成功");
this.setPath("docMana.action");
}
return "succeed";
}
我想问下怎么把前台的ids数组传到后台action中,多谢! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询