删除成功或失败,在前台alert提示信息,并跳转页面
@RequestMapping("/delete.do")
public void deleteNews(String option, String id, HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
String[] ids = null;
if (option.equals("deleteOnes")) {
ids = id.split("/");
}else {
ids = new String[] {id};
}
int row = ns.deleteNewsById(ids);
try {
PrintWriter writer = response.getWriter();
String msg = null;
if (row > 0) {
msg = "alert( '删除成功' );location.href='toIndex.do'";
}else {
msg = "alert('删除失败');history.go(-1)";
}
writer.print("<script type='text/javascript'>" + msg + "</script>");
writer.flush();
writer.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
————————————————
版权声明:本文为CSDN博主「采采茶」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44251024/article/details/86130489