后台action处理数据传递给前台界面

时间:2022-11-15 08:19:04
package com.renmai.util;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

public class ResponseUtil {

	public static void  writeGBK(HttpServletResponse response,String content) {
		response.setContentType("text/html;charset=GBK");
		try {
			response.getWriter().print(content);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public static void  writeUTF(HttpServletResponse response,String content) {
		response.setContentType("text/html;charset=UTF-8");
		try {
			response.getWriter().print(content);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

action调用代码:

	ResponseUtil.writeGBK(getHttpResponse(), "<script>alert('"
						+ msg + "');history.back();</script>");
				return null;