如何从使用jsp的数据库打印的表中删除特定的用户行

时间:2014-07-19 13:49:38

标签: java mysql jsp

在我的动态网站上,我正在写关于管理员的部分。他可以看到所有注册用户,并可以删除其中一个或多个。问题是我不了解如何传递特定用户ID。

我的代码是:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

    <table border="1">
        <thead><tr>
                        <th>NAME</th>
                        <th>SURNAME</th>
                        <th>USERSID</th>
                        <th>USERNAME</th>
                        <th>PASSWORD</th>
                        <th>EMAIL</th>
                        <th>ROLE</th>
                        <th>ACTIONS</th>
                    </tr>
        </thead>

        <tbody>
            <% 
                Vector<String[]> risultati = AmministratoreDAO.getInstance().getListUsers();

                //prova
                String riga2 = "0";

                if(risultati.size()>0)
                {
                    for(int i=0; i<risultati.size(); i++)
                    {
                        String[] riga = risultati.get(i);
                        out.print("<tr>");


        riga2 = riga[2];
                session.setAttribute("codicefiscale", riga2);

                for(int j=0; j < riga.length; j++)
                {
                    out.append("<td>" + riga[j] + "  </td>");
                }


                out.print(" <td><a href='AdminDeleteUser.jsp'?id=+riga[2]> cancellare</a></td>"); 
            out.print("</tr>"); 
                }
            }else{
            out.print("NON CI SONO RISULTATI");
        }
            %>

        </tbody>

    </table>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

out.print(" <td><a href='AdminDeleteUser.jsp'?id=+riga[2]> cancellare</a></td>"); 
==================================================================================
instead of you should write like this
out.print(" <td><a href='AdminDeleteUser.jsp?id=riga[2]'> cancellare</a></td>"); 

现在获取id

String str=request.getParameter("id");