日期:2014-05-19 浏览次数:20679 次
<a href="javascript:onclickDel(this.id,'Del')" id="当前记录主键编号">删除<a>
<a href="javascript:onclickEdit(this.id,'Edit')" id="当前记录主键编号">修改<a>
function onclickDel(ids,types){
if(types=="Del"){
window.location.href="删除的servlet?ids="+ids;
}else{
window.location.href="修改的servlet?ids="+ids;
}
}
package com.briup.service;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.briup.common.FactroyBean;
import com.briup.pojo.User;
import com.sun.faces.config.beans.FactoryBean;
public class ManagerServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
IUserService service=FactroyBean.getUserService();
//查找所有的用户
List<User> list=service.findAll();
out.println("<html><body><center><table border='1px'>");
out.println("<tr><td>用户名</td><td>密码</td><td>性别</td>");
out.println("<td>爱好</td><td>城市</td><td>简介</td><td>按钮1</td><td>按钮2</td></tr>");
for(int i=0;i<list.size();i++){
String name=list.get(i).getName();
String password=list.get(i).getPassword();
String gender=list.get(i).getGender();
String hobby=list.get(i).getHobby();
String city=list.get(i).getCity();
String info=list.get(i).getInfo();
out.println("<tr><td>"+name+"</td>");
out.println("<td>"+password+"</td>");
out.println("<td>"+gender+"</td>");
out.println("<td>"+hobby+"</td>");
out.println("<td>"+city