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);
}
}
最近下载更多
微信网友_7041486630686720 LV2
2024年6月17日
educationAAA LV11
2024年6月7日
sunlea LV20
2024年5月17日
123456wadff LV3
2024年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日
最近浏览更多
一个神秘人 LV1
10月22日
AniyaKKbi
8月28日
暂无贡献等级
ttg2025 LV3
8月22日
1_小飞飞_1 LV2
5月25日
benben2020
3月19日
暂无贡献等级
abdkfksdkf LV16
2月23日
林kkkkkk LV6
2月8日
tel3033 LV1
1月21日
微信网友_7294439741132800 LV1
2024年12月13日
微信网友_7290593889931264
2024年12月10日
暂无贡献等级

