首页>代码>企业人力资源管理项目SSH+EXTJS+MySQL整合开发>/hrmsys/src/com/hrmsys/action/BaseAction.java
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);
	}
}
最近下载更多
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日
and123456  LV11 2022年2月7日
最近浏览更多
guaixia163  LV13 4月7日
GakkiMarryMe  LV9 4月4日
邓艺妮 4月3日
暂无贡献等级
 LV7 3月25日
yuan666  LV1 3月11日
1134116035 2月26日
暂无贡献等级
晴曛  LV6 2月20日
midyn203  LV2 2月5日
森sdfgf  LV8 2月5日
PSSDZH  LV3 1月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友