点击删除没有完全没反应,来神救救我,调了几个小时。。。
jsp:
<a class="btn03" href="JavaScript:deleteList('<%=basePath%>');">删 除</a></p>
<th><input type="checkbox" name="id" value="${message.id}"/></th>
js:
function deleteList(basePath) {
$("#mainForm").attr("action",basePath + "DeleteList.action");
$("#mainForm").submit();
}
servlet:
*/
public class DeleteListServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//设置编码
req.setCharacterEncoding("UTF-8");
//接受页面的值(String数组)
String[] ids = req.getParameterValues("id");
MaintainService maintainService = new MaintainService();
maintainService.deleteList(ids);
req.getRequestDispatcher("/List.action").forward(req,resp);
}
web.xml:
<servlet>
<servlet-name>DeleteListServlet</servlet-name>
<servlet-class>main.java.Servlet.DeleteListServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DeleteListServlet</servlet-name>
<url-pattern>/DeleteList.action</url-pattern>
</servlet-mapping>