package com.hrmsys.action; /** * @author sux * @date 2011-01-10 * @class BaseAction */ import java.io.IOException; import java.io.PrintWriter; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class BaseAction extends ActionSupport{ Log log = LogFactory.getLog("BaseAction.class"); /** * by ServletActionContext get Response * @return response */ public HttpServletResponse getResponse(){ HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html; charset=UTF-8"); return response; } public HttpServletRequest getRequest(){ return ServletActionContext.getRequest(); } /** * get session * @return */ public Map<String, Object> getSession(){ return ActionContext.getContext().getSession(); } /** * Open PrintWriter * @return */ public PrintWriter getWriter(){ HttpServletResponse response = this.getResponse(); PrintWriter pw = null; try { pw = response.getWriter(); } catch (IOException e) { e.printStackTrace(); } return pw; } /** * close PrintWriter * @param out */ public void close(PrintWriter out){ if(out != null){ out.close(); } } /** * write json string * @param json */ public void out(String json){ PrintWriter out = this.getWriter(); out.write(json); this.close(out); } }
最近下载更多
sunlea LV18
前天
123456wadff LV3
1月15日
Seaskye LV14
2023年11月4日
yuanye111 LV2
2023年3月12日
微信网友_6308169330069504 LV2
2023年1月17日
sandihha LV9
2022年12月28日
东方明亮 LV5
2022年12月4日
松雅倨仕i LV7
2022年6月16日
园林属于 LV7
2022年6月6日
蛇蛇皮怪 LV14
2022年3月8日
最近浏览更多
ma406805131 LV12
5月6日
hmf1989
4月26日
暂无贡献等级
educationAAA LV6
4月23日
guaixia163 LV13
4月7日
GakkiMarryMe LV9
4月4日
邓艺妮
4月3日
暂无贡献等级
黑 LV7
3月25日
yuan666 LV1
3月11日
1134116035
2月26日
暂无贡献等级
晴曛 LV6
2月20日