java - Login Interceptor(Custom Interceptor) clearing the Action Parameters -
here interceptor code:-
public class logininterceptor extends abstractinterceptor implements strutsstatics { /** * */ private static final long serialversionuid = 1l; @override public string intercept(actioninvocation invocation) throws exception { actioncontext context = invocation.getinvocationcontext(); httpservletrequest request = (httpservletrequest) context .get(http_request); httpsession session = request.getsession(false); string loginid = (string) session .getattribute(constants.session_att_userid); if (loginid == null) { return action.login; } else { return invocation.invoke(); } } } when calling particular action interceptor been called. parameters of action getting null. if running code without interceptor, working fine. tried resolving many ways couldn't find solution.
when want use interceptor, need add defaultstack, or customstack of your, while have used interceptor action. means other interceptor not running action invocation, not parameter interceptor, responsible setting parameters in action.
wrong:
<action name="foo" class="org.foo.bar.foobaraction"> <interceptor-ref name="mylogininterceptor"/> <result>success.jsp</result> </action> right:
<action name="foo" class="org.foo.bar.foobaraction"> <interceptor-ref name="mylogininterceptor"/> <interceptor-ref name="defaultstack"/> <result>success.jsp</result> </action>
Comments
Post a Comment