struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cantalou89 <cantalo...@gmail.com>
Subject Re: struts2 Intercepter Actioncontext
Date Fri, 24 May 2013 22:50:07 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message