欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ssh框架前台弹出警告框

程序员文章站 2022-05-31 15:58:31
...

直接上代码:
action类实现下面的这个接口:
public class UserAdminAction extends ActionSupport implements ModelDriven, ServletResponseAware {

private HttpServletRequest request = null;
private HttpServletResponse response;

public HttpServletRequest getRequest() {
	return request;
}

public void setRequest(HttpServletRequest request) {
	this.request = request;
}

public HttpServletResponse getResponse() {
	return response;
}

public void setResponse(HttpServletResponse response) {
	this.response = response;
}


// 后台用户的删除
public String delete() {

	PageBean<Order> orders = orderService.findByUid(user.getUid(), 1);

	if (orders != null) {
		System.out.println("删除失败-----");
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");// 防止弹出的信息出现乱码
		try {
			PrintWriter out = response.getWriter();
			out.print("<script>alert('此用户存在数据关联,请不要删除!')</script>");
			out.print(
					"<script>window.location.href='http://localhost:8080/shop/userAdmin_findAll1.action'</script>");
			out.flush();
			out.close();

		} catch (IOException e) {
			e.printStackTrace();
		}

	} else {
		User existUser = userService.findByUid(user.getUid());
		userService.delete(existUser);
		System.out.println("删除成功");
	}
	return "deleteSuccess";
}

public void setServletResponse(HttpServletResponse response) {
	this.response = response;

}

}
ssh框架前台弹出警告框

相关标签: ssh