首页 > 编程语言 > 详细

spring之controller中alert操作

时间:2014-12-29 02:05:09      阅读:1076      评论:0      收藏:0      [点我收藏+]

需求:

Controller层直接alert

实现:

protected String alert(HttpServletResponse response, String msg, String url) {
	response.setCharacterEncoding("UTF-8");
	response.setHeader("Content-type", "text/html;charset=UTF-8");
	PrintWriter out = null;
	try {
		out = response.getWriter();
		out.print("<script>alert(‘" + msg + "‘);window.location.href=‘"
				+ url + "‘;</script>");
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		IOUtils.closeQuietly(out);
	}
	return "common/suc";

}

protected void alertAndclose(HttpServletResponse response, String msg) {
	response.setCharacterEncoding("UTF-8");
	response.setHeader("Content-type", "text/html;charset=UTF-8");
	PrintWriter out = null;
	try {
		out = response.getWriter();
		out.print("<script>alert(‘" + msg + "‘);window.close();</script>");
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		IOUtils.closeQuietly(out);
	}

}

?

spring之controller中alert操作

原文:http://snv.iteye.com/blog/2170702

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!