In the Intercepter , you can try  
WebApplicationContext context = 
WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletConfig.getServletContext());
after you get request.



cantalou89

From: john lee
Date: 2013-05-25 03:17
To: struts support
Subject: struts2 Intercepter Actioncontext


In an cutomized Struts2 Intercepter class, 

    public class SecurityVerifySessionIntercepter extends AbstractInterceptor
          ActionContext actionContext = invocation.getInvocationContext();
          HttpServletRequest request= (HttpServletRequest) 
actionContext.get(StrutsStatics.HTTP_REQUEST);
          Map session = actionContext.getSession();

the above program works without any problem

however,

   if i want to access WebApplicationContext, i have to get 
ServletActionContext first as the following
         WebApplicationContext 
context=WebApplicationContextUtils.getRequiredWebApplicationContext(ServletActionContext.getServletContext());
   the compile complain can not find ServletActionContext.

   for the regular Struts2 action class extends ActionSupport, then i have no 
problem to get ServletActionContext, but failed in Intercepter.

Question is:

    I already extends AbstractInterceptor for use interceptor, certainly i can 
not extends ActionSupport any more.
    then how can i access ServletActionContext in the interceptor?
    without extends Actionsupport, can i get ServletActionContext from 
ActionContext? how to convert?

please advise

john

Reply via email to