在寫struts2攔截器的時候,有時會須要獲取session對象或request對象,能夠用如下方式來獲取session
// 獲取sessionspa
Map<String, Object> session = invocation.getInvocationContext()對象
.getSession();get
//獲取requestit
ActionContext ac = invocation.getInvocationContext();io
HttpServletRequest request = (HttpServletRequest) acstruts2
.get(ServletActionContext.HTTP_REQUEST);request