Action中获取servletAPI对象的方法

1、ServletActionContext:可以从中获取当前Action对象需要的一切ServletAPI的相关对象;

常用的方法:

  1、获取HttpServletRequest:ServletActionContext.getRequest();

  2、获取HttpSession:ServletActionContext.getRequest().getSession();

  3、获取ServletContext:ServletActionContext.getServletContext();

2、通过实现servletXXXAware接口(如ServletRequestAware,ServletContextAware,ServletResponseAware等)

注入需要的servlet的相关对象

原文地址:https://www.cnblogs.com/hongcong/p/6043491.html