Note that there are some explanatory texts on larger screens.

plurals
  1. POInterceptor prevents URL parameters from being passed to actions
    primarykey
    data
    text
    <p>I've got a LoginInterceptor that runs before most actions and checks if the member is logged in or not. If it is, the page is shown, otherwise it is redirected to login page.</p> <p>However I just noticed the interceptor "blocks" all URL parameters. Basically if there is an interceptor before an action, URL parameters for this action won't be passed to setters.</p> <p>This is my interceptor:</p> <pre><code>public class LoginInterceptor extends AbstractInterceptor { public String intercept(final ActionInvocation invocation) throws Exception { final String REDIR = "loginRedirect"; AuthenticationService auth = new AuthenticationService(); if (auth.isMemberLoggedIn()) { return invocation.invoke(); } else { return REDIR; } } } </code></pre> <p>I suspect the <code>invocation.invoke()</code> invokes the action, but without the parameters.</p> <p>What can I do about it?</p> <p>UPDATE:</p> <p><strong>AuthenticationService.isMemberLoggedIn()</strong></p> <pre><code>public boolean isMemberLoggedIn() { Map&lt;String, Object&gt; session = ActionContext.getContext().getSession(); String username = (String) session.get("username"); if (username != null) { return true; } else { return false; } } </code></pre> <p><strong>struts.xml</strong></p> <pre><code>&lt;package name="global" extends="struts-default"&gt; &lt;interceptors&gt; &lt;interceptor name="loginInterceptor" class="community.interceptor.LoginInterceptor" /&gt; &lt;/interceptors&gt; &lt;global-results&gt; &lt;result name="loginRedirect" type="redirect"&gt;/members/login&lt;/result&gt; &lt;/global-results&gt; &lt;/package&gt; </code></pre> <p>Then each package extends <code>global</code> and I invoke them in each action:</p> <pre><code>&lt;interceptor-ref name="loginInterceptor" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload