JAVA怎么用Checkbox删除数据库内多条记录 我现在做的只能删除一条 但是不能删除多条,请问应该怎么做? 10
这是Struts跳转的页面获得Dao里面的rows值返回deletepackageaction;importMyBean.Dao;importMyBean.cunqu;i...
这是Struts跳转的页面 获得Dao里面的rows值 返回delete
package action;
import MyBean.Dao;
import MyBean.cunqu;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import MyBean.cunqu;
public class ActionDelete {
private String xuehao;
private long[]xh=new long[]{};
public String getXuehao() {
return xuehao;
}
public void setXuehao(String xuehao) {
this.xuehao = xuehao;
}
public String execute() throws Exception{
String xuehao=ServletActionContext.getRequest().getParameter("xuehao");
Dao dao = new Dao();
int rows = 0;
try {
rows=dao.shanchu(xuehao);
} catch (Exception e) {
e.printStackTrace();
}
if(rows==1){
return "delete";
}
else{
return "fail";
}
}
}
这是Dao类
public int shanchu(String xuehao) throws Exception{
Connection connection = this.getConnection();
Statement stm = connection.createStatement();
下面应该怎么写 展开
package action;
import MyBean.Dao;
import MyBean.cunqu;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import MyBean.cunqu;
public class ActionDelete {
private String xuehao;
private long[]xh=new long[]{};
public String getXuehao() {
return xuehao;
}
public void setXuehao(String xuehao) {
this.xuehao = xuehao;
}
public String execute() throws Exception{
String xuehao=ServletActionContext.getRequest().getParameter("xuehao");
Dao dao = new Dao();
int rows = 0;
try {
rows=dao.shanchu(xuehao);
} catch (Exception e) {
e.printStackTrace();
}
if(rows==1){
return "delete";
}
else{
return "fail";
}
}
}
这是Dao类
public int shanchu(String xuehao) throws Exception{
Connection connection = this.getConnection();
Statement stm = connection.createStatement();
下面应该怎么写 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询