<%
List<Users> usersli = (List) request.getAttribute("usersli");
Users users;
/*Debug*/System.out.println("show_users.jsp");
if (usersli !=null) {
for (int i = 0; i < usersli.size(); i++) {
users = (Users)usersli.get(i);
%>
< tr>
< td><%=users.getUser()%>
< td><%=users.getPassword()%>
< td><%=users.getNumber()%>
< td><%=users.getRoot()%>
< td>
< form id="form2" name="form2" method="post" action="">
< input type="submit" name="updata" id="updata" value="編輯" />
< input type="submit" name="del" id="del" value="刪除" />
< /form>
< /td>
< /tr>
<%
}
}
SERVLET代碼:
private void show(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
String root =(String)request.getParameter("chooseroot");
String user = (String)request.getParameter("condition");
/*Debug*/System.out.println("ShowServlet.show(),權限="+root+",條件="+user);
UsersDAO usersDAO = new UsersDAO();
List<?> usersli= new ArrayList<Object>();
usersli = usersDAO.show(root,user);
//list傳遞
request.setAttribute("usersli", usersli);
request.getRequestDispatcher("../show/show_users.js").forward(request,response);
//request.getSession().setAttribute("usersli",usersli );
//response.sendRedirect("../show/show_users.jsp");
}
request.getRequestDispatcher("../show/show_users.js").forward(request,response);
相對路徑寫錯了,js->jsp就好了