用户请求动作

/**
* 用户请求动作
* @author RuiLin.Xie - xKF24276
*/
public class BaseAction extends HttpServlet
{

/**
* 序列号
*/
private static final long serialVersionUID = 1L;

/**
* 处理Get
*/
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
initCookie(req, resp);

//根据用户请求解析出用户动作及提交参数
RequestPackage rp = ActionBizFactory.getActionBizFactory().reqToRequestPackage(req, resp);

System.out.println(rp.getAction());
if(rp.getAction().startsWith("PoseStaticPage") || rp.getAction().length() == 0 || rp.getAction().equals("index"))
req.getRequestDispatcher("index.jsp").forward(req, resp);

//执行业务并响应用户
ActionBizFactory.getActionBizFactory().exec(rp);
}

/**
* 处理POST
*/
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
doGet(req, resp);
}


/**
* 读取配置文件初始化配置
*/
public void init() throws ServletException
{
//得到配置文件路径
String filePath = this.getServletConfig().getServletContext().getRealPath("/");
filePath = filePath + "WEB-INF\\action.conf";

//初始化到ActionBizFactory 的 actionMap

super.init();
}

/**
* 初始化Cookie,防止非法下载
* @param request
* @param response
*/
private void initCookie(HttpServletRequest request, HttpServletResponse response)
{
Object oFurl = request.getSession().getAttribute("FURL");
String ccookie = request.getHeader("Cookie");

if(oFurl == null || ccookie.indexOf("FURL") == -1)
{
//加密URL
String fromUrl = request.getRequestURL().toString();

Cookie cookie = new Cookie("FURL", fromUrl);
response.addCookie(cookie);
request.getSession().setAttribute("FURL", fromUrl);

}
}

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值