http参数通常直接封装在Action中,action访问Servlet API的方法
jsp能访问到数据,通过post还能修改数据。当然也可以把数据存在application中(是map键值对形式),用ActionContext类,需要import
ActionContext ac = ActionContext.getContext();
ac.getApplication().put("username", username);
getApplication返回的是Map<String,object> ,String值要双引号,否则之后找不到。所以说是间接访问Application
Action使用非IoC方式直接访问Servlet API:需要import
import javax.servlet.ServletContext;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork1.ActionSupport;
ServletContext application = ServletActionContext.getServletContext();
application.setAttribute("username", username);
ServletActionContext 还有getPageContext() getRequest() getResponse()静态方法