躲避酒驾:关于Servlet删除操作的总结
来源:百度文库 编辑:九乡新闻网 时间:2024/10/10 14:05:25
在Servlet的doPost()函数里面的代码如下: String pid = request.getParameter("id");
String fromURL = request.getParameter("fromURL");
String[] idList = request.getParameterValues("C_item");
PositionDao pdao = new PositionDao();
int id = 0;
StringBuffer message = new StringBuffer();
if(idList!=null)
{
for(int i=0;i {
try{
id = Integer.parseInt(idList[i]);
boolean b = pdao.delPositionById(id);
if(b)
{
message.append("简历 "+id+" 删除成功!
");
}else{
message.append("简历 "+id+" 删除失败!
");
}
}catch(ClassCastException e){
e.printStackTrace();
}
}
}else{
try{
id = Integer.parseInt(pid);
boolean b = pdao.delPositionById(id);
if(b)
{
message.append("简历 "+id+" 删除成功!
");
}else{
message.append("简历 "+id+" 删除失败!
");
}
}catch(ClassCastException e)
{
e.printStackTrace();
}
}
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("A Servlet ");
out.println("");
out.print(message);
out.print("");
out.println(" ");
out.println("");
out.flush();
out.close(); 程序执行只接收了红色字体部分的参数,而后面紫色部份代码则无论删除对象是什么类型都是相似的,尤其是如果dao采用了接口模式之后,函数都是同一的,因此可以整合到单独的类当中去,节省写代码的时间。
String fromURL = request.getParameter("fromURL");
String[] idList = request.getParameterValues("C_item");
PositionDao pdao = new PositionDao();
int id = 0;
StringBuffer message = new StringBuffer();
if(idList!=null)
{
for(int i=0;i
try{
id = Integer.parseInt(idList[i]);
boolean b = pdao.delPositionById(id);
if(b)
{
message.append("简历 "+id+" 删除成功!
");
}else{
message.append("简历 "+id+" 删除失败!
");
}
}catch(ClassCastException e){
e.printStackTrace();
}
}
}else{
try{
id = Integer.parseInt(pid);
boolean b = pdao.delPositionById(id);
if(b)
{
message.append("简历 "+id+" 删除成功!
");
}else{
message.append("简历 "+id+" 删除失败!
");
}
}catch(ClassCastException e)
{
e.printStackTrace();
}
}
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("
out.println("
out.print(message);
out.print("");
out.println("
out.println("");
out.flush();
out.close(); 程序执行只接收了红色字体部分的参数,而后面紫色部份代码则无论删除对象是什么类型都是相似的,尤其是如果dao采用了接口模式之后,函数都是同一的,因此可以整合到单独的类当中去,节省写代码的时间。
关于Servlet删除操作的总结
servlet的生命周期
介绍一篇关于session的好文章,写的很详细(jsp-servlet 技术) 收藏
关于变电所的操作
关于人性的总结
关于“人”的总结
Servlet 2.5的新特征
关于操作轮链过程中的一些总结
关于变电所的操作2
关于变电所的操作gc
关于变电所的操作c
总结:六种删除数据库重复行的方法
新手总结的神机操作(安装)
被总结出来的健康操作规则
网友兰莽的操作总结
关于人性的些许总结
关于人性的些许总结
关于人性的些许总结
关于套筒冠的总结
关于MSP430的学习总结
关于人性的些许总结
关于国共内战的总结
servlet的生命周期-完全没看懂
JSP和Servlet对中文的处理