Java中的重定向问题(Wicket)

Java中的重定向问题(Wicket),java,frameworks,wicket,Java,Frameworks,Wicket,我有一个从网页继承的页面,受下面的类保护: public final class WiaAuthorizationStrategy implements IAuthorizationStrategy, IUnauthorizedComponentInstantiationListener { private RealmPolicy roleManager; private static WiaAuthorizationStrategy insta

我有一个从网页继承的页面,受下面的类保护:

public final class WiaAuthorizationStrategy implements
        IAuthorizationStrategy,
        IUnauthorizedComponentInstantiationListener {

    private RealmPolicy roleManager;
    private static WiaAuthorizationStrategy instance;

    private WiaAuthorizationStrategy() {
        roleManager = RealmPolicy.getInstance();
    }

    public static WiaAuthorizationStrategy getInstance() {
        if(instance == null)
            instance = new WiaAuthorizationStrategy();
        return instance;
    }

    public boolean isInstantiationAuthorized(Class componentClass) {

        if (ProtectedPage.class.isAssignableFrom(componentClass)) {
            if (WiaSession.get().getUser() == null) {
                return false;
            }
            if(!roleManager.isAuthorized(WiaSession.get().getUser().getRole(), componentClass.getName()))//WiaSession.get().isAuthenticated();
            {
                WiaSession.get().setAccess(false);
                return false;
            }
            else
                return true;
        }

        return true;
    }

    public void onUnauthorizedInstantiation(Component component) {
        throw new RestartResponseAtInterceptPageException(
                Login.class);
    }

    public boolean isActionAuthorized(Component component, Action action) {
        //System.out.println("Name:" + component.getClass().getName() + "\n Action:" + action.getName() + "\nUser:" + WiaSession.get().getUser());
        if (action.equals(Component.RENDER)) {
            if (roleManager.containClass(component.getClass().getName()))
             {
                if (WiaSession.get().getUser() != null) {
                    if(!roleManager.isAuthorized(WiaSession.get().getUser().getRole(), component.getClass().getName()))
                    {
                        WiaSession.get().setAccess(false);
                        return false;
                    }
                    return true;
                }
                return false;
            }
        }
        return true;
    }
}
当我进入该页面时,一切正常,但当我按Ctrl+F5时,页面重定向到登录页面,这是设置受保护页面的默认设置。 我试着调试代码,发现ProtectedPage类中的super()函数可以这样做,在调试过程中我无法输入这部分代码。该类存在于以下位置:

public abstract class ProtectedPage extends WebPage {

    public ProtectedPage() {
---->>>超级(); verifyAccess(); }

    protected void verifyAccess() {
// Redirect to Login page on invalid access.
        if (!isUserLoggedIn()) {
            throw new RestartResponseAtInterceptPageException(Login.class);
        }
    }

    protected boolean isUserLoggedIn() {
        return ((WiaSession) getSession()).isAuthenticated();
    }
}
我已经用-->>>>在代码中签名了。
有人能帮我解决这个问题吗?

ctrl+F5应该怎么做

您有一些键绑定问题吗


你不能重定向吗?你到底有什么问题?

当你安装了IAuthorizationStrategy时,不要使用verifyAccess之类的工具;后者应该为您完成全部工作。

WiaSession.isAuthenticated()的逻辑是什么


(不要忽略Eelco的评论,只是寻找根本原因)

当我刷新我的页面或做一些需要联系到服务器的事情时,页面被重定向到登录页面很高兴在这里看到你Eelco,真的很喜欢Wicket的行动!