it is interceptor, the following is struts.xml, (i just not include last time)
<struts>
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="securityverifysessionIntercepter" class="SecurityVerifySessionIntercepter">
</interceptor>
<interceptor-stack name="SecurityStack">
<interceptor-ref name="securityverifysessionIntercepter"/>
</interceptor-stack>
</interceptors>
<action name="LoginAction" class="LoginAction">
<interceptor-ref name="SecurityStack"/>
<result name="input">PageLogin.jsp</result>
<result name="success">PageMain.jsp</result>
</package>
</struts>
________________________________
From: Dave Newton <davelnewton@gmail.com>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Thursday, May 23, 2013 4:31 PM
Subject: Re: struts 2 Intercepter ServletRequestAware
That interface is for actions, not interceptors.
On May 23, 2013 5:30 PM, "john lee" <sh_thorn_bird@yahoo.com> wrote:
> Please advise the following
>
> for struts2, for an login action, an predefined interceptor is triggered
> for checking cookie , the code is the following
>
> for SecurityVerifySessionIntercepter, i implement the
> ServletRequestAware, but get null catached.
>
> my question is:
>
> for intercepter, Request object can not be implemented? if can, why i get
> null?
>
> thanks in advance
>
> john
>
>
>
> public class SecurityVerifySessionIntercepter extends AbstractInterceptor
> implements ServletResponseAware, ServletRequestAware {
>
>
> protected HttpServletResponse servletResponse;
> public void setServletResponse(HttpServletResponse servletResponse)
> { this.servletResponse = servletResponse; }
>
> protected HttpServletRequest servletRequest;
> public void setServletRequest(HttpServletRequest servletRequest) {
> this.servletRequest = servletRequest; }
>
> public String intercept(ActionInvocation invocation) throws Exception {
>
> ActionContext ctx=invocation.getInvocationContext();
> Map session= ctx.getContext().getSession();
>
> if (servletRequest==null)
> System.out.println(" Request object is null catched");
> Cookie cookieList[]=servletRequest.getCookies();
>
|