1. 程式人生 > >java實現刪除某條資訊並重新整理當前頁

java實現刪除某條資訊並重新整理當前頁

//執行的是刪除資訊的操作
        String a=request.getParameter("name");
         a = URLEncoder.encode(a, "ISO-8859-1");
         String name = URLDecoder.decode(a, "UTF-8");
        String num=request.getParameter("num");
        System.out.println("name:"+name+"num:"+num);
        String sql="delete  from person_info where name=? and num=?";
        String sz[]={name,num};
        JdbcUtils.update(sql, sz);
        //重新整理操作
        String sqls="select * from person_info";
        ResultSet rs=JdbcUtils.select(sqls, null);
        ArrayList<Person_info> list=new ArrayList<Person_info>();
        try {
            while(rs.next()){
                Person_info pi=new Person_info(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6));
                list.add(pi);
            }
            request.setAttribute("list", list);
            request.getRequestDispatcher("Personnel_definition.jsp").forward(request, response);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
    }

在這裡插入圖片描述