2016-08-17 69 views
0

從Wicket 6.23.0升級到7.4.0之後,我的Wicket頁面上的登錄不再起作用。使用Spring Security 4.1登錄失敗Wicket 7

我得到一個PageExpiredException:

14:50:31,772 WARN [RequestCycleExtra] (default task-20) ******************************** 
14:50:31,773 WARN [RequestCycleExtra] (default task-20) Handling the following exception: org.apache.wicket.protocol.http.PageExpiredException: Bookmarkable page with id 'null' has expired. 
14:50:31,774 WARN [RequestCycleExtra] (default task-20) ******************************** 

的LoginPage看起來是這樣的:

@MountPath("login") 
public class LoginPage extends WebPage { 

private static final long serialVersionUID = 1L; 

public LoginPage() { 
} 

@Override 
public void renderHead(IHeaderResponse response) { 
    super.renderHead(response); 
    response.render(JavaScriptReferenceHeaderItem.forReference(JQueryJavaScriptResourceReference.get())); 
    response.render(JavaScriptReferenceHeaderItem.forReference(JQueryUiJavaScriptResourceReference.get())); 
    response.render(CssContentHeaderItem.forReference(JQueryUiCssResourceReference.get())); 
} 

@Override 
protected void onInitialize() { 
    super.onInitialize(); 

    IModel<AuthenticationData> model = new CompoundPropertyModel<>(new AuthenticationData()); 

    add(new FeedbackPanel("feedbackPanel")); 

    @SuppressWarnings("serial") 
    StatelessForm<AuthenticationData> form = new StatelessForm<AuthenticationData>("form", model) { 

     /** {@inheritDoc} */ 
     @Override 
     protected void onSubmit() { 
      WebSession session = WebSession.get(); 
      if (session.signIn(getModelObject().getUserName(), getModelObject().getPassword())) { 
       setResponsePage(getApplication().getHomePage()); 
      } else { 
       error("Login failed due to invalid credentials"); 
      } 
     } 
    }; 
    add(form); 

    TextField<String> userNameTextField = new TextField<>("userName"); 
    form.add(userNameTextField); 

    PasswordTextField passwordTextField = new PasswordTextField("password"); 
    form.add(passwordTextField); 

    SubmitLink submitLink = new SubmitLink("submitLink"); 
    form.add(submitLink); 
     form.setDefaultButton(submitLink); 
    } 

} 

永遠達不到StatelessForm的方法的onsubmit。

的設置是simular到這裏:https://ci.apache.org/projects/wicket/guide/7.x/guide/security.html#security_1

回答

0

問題是在LoginPage的StatelessForm:

@MountPath("login") 
public class LoginPage extends WebPage { 

private static final long serialVersionUID = 1L; 

public LoginPage() { 
} 

@Override 
public void renderHead(IHeaderResponse response) { 
    super.renderHead(response); 
    response.render(JavaScriptReferenceHeaderItem.forReference(JQueryJavaScriptResourceReference.get())); 
    response.render(JavaScriptReferenceHeaderItem.forReference(JQueryUiJavaScriptResourceReference.get())); 
    response.render(CssContentHeaderItem.forReference(JQueryUiCssResourceReference.get())); 
} 

@Override 
protected void onInitialize() { 
    super.onInitialize(); 

    IModel<AuthenticationData> model = new CompoundPropertyModel<>(new AuthenticationData()); 

    add(new FeedbackPanel("feedbackPanel")); 

    @SuppressWarnings("serial") 
    Form<AuthenticationData> form = new Form<AuthenticationData>("form", model) { 

     /** {@inheritDoc} */ 
     @Override 
     protected void onSubmit() { 
      WebSession session = WebSession.get(); 
      if (session.signIn(getModelObject().getUserName(), getModelObject().getPassword())) { 
       setResponsePage(getApplication().getHomePage()); 
      } else { 
       error("Login failed due to invalid credentials"); 
      } 
     } 
    }; 
    add(form); 

    TextField<String> userNameTextField = new TextField<>("userName"); 
    form.add(userNameTextField); 

    PasswordTextField passwordTextField = new PasswordTextField("password"); 
    form.add(passwordTextField); 

    SubmitLink submitLink = new SubmitLink("submitLink"); 
    form.add(submitLink); 
     form.setDefaultButton(submitLink); 
    } 

}