开发者

Form not redirecting correctly Wicket

private void setDefaultResponsePageIfNecessary() {

    if(!continueToOriginalDestination()) {
        if(session.getRoles().equals("ROLE_ADMIN")){
            setResponsePage(SearchForCapacity.class);
            System.out.println("Role for Admin:" + session.getRoles());
        } else if (session.getRoles().equals("ROLE_USER"));
            setResponsePage(HomePage.class);
            System.out.println("Role for User: " + session.getRoles());
    }
}

Hi all, this extract is from my login class which works fine except it wont redirect to the correct page. I can print the roles to the console so for admin it will print ROLE_ADMIM etc. The 开发者_如何学JAVAproblem is no matter what the role it always navigates to the same page (HomePage), does anyone know why this is? thanks.


The else if statement is terminated by a ; instead of opening a block with {.

private void setDefaultResponsePageIfNecessary() {

    if(!continueToOriginalDestination()) {
        if(session.getRoles().equals("ROLE_ADMIN")){
            setResponsePage(SearchForCapacity.class);
            System.out.println("Role for Admin:" + session.getRoles());
        } else if (session.getRoles().equals("ROLE_USER")) {
            setResponsePage(HomePage.class);
            System.out.println("Role for User: " + session.getRoles());
        }
    }
}


You should also use getRoles().contains() instead of getRoles().equals().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜