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(), ""); return null;