2011-02-09 62 views
2

我創建了兩個模塊GWT和SpringSecurity

  1. GWTAppAuth
  2. GWTApp

當我嘗試從GWTAppAuthj_spring_security_check什麼形式張貼發生。

螢火顯示在控制檯

"Failed to load source for:http://127.0.0.1:8888/j_spring_security_check" 

但是,如果我以後嘗試手動訪問GWTApp它的工作原理。任何人都知道什麼是問題?

看起來像Spring Security只是不重定向到第二個(GWTApp)。
如何檢查?在託管模式

    1. 運行應用程序試圖訪問GWTApp.html
    2. 春季安全重定向我GWTAppAuth.html
    3. 按下登錄按鈕

    在這個地方,如果我們檢查螢火蟲日誌我們可以看到

    "POST //127.0.0.1:8888/j_spring_security_check" 
    

    和響應 -

    "Failed to load source for: http://127.0.0.1:8888/j_spring_security_check" 
    

    然後下一個記錄 -

    "GET //127.0.0.1:8888/GWT/GWTApp.html?gwt.codesvr=127.0.0.1:9997" 
    

    ,並獲取所有所需資源
    現在,我可以手動輸入

    "//127.0.0.1:8888/GWT/GWTApp.html" 
    

    ,現在我有機會獲得GWTApp.html

  • 回答

    4

    我找到了解決方案。
    您應該使用HTML表單並提交按鈕,而不是通過小部件GWT 例如提供:

    <form action="/j_spring_security_check" method="post"> 
        <g:Label> 
         login 
        </g:Label> 
        <g:TextBox name="j_username" width="200" /> 
         <g:Label> 
          password 
         </g:Label> 
         <g:PasswordTextBox name="j_password" width="200" /> 
         <input name="submit" type="submit" value="Login" /> 
    </form> 
    

    或趕上形式提交的情況下完成的事件您使用GWT FormPanel中部件:

    public class LoginFormB extends Composite { 
    
        private static LoginFormBUiBinder uiBinder = GWT.create(LoginFormBUiBinder.class); 
    
        interface LoginFormBUiBinder extends UiBinder<Widget, LoginFormB> {} 
    
        @UiField 
        FormPanel formPanel; 
    
        public LoginFormB() { 
        formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { 
    
         @Override 
         public void onSubmitComplete(SubmitCompleteEvent arg0) { 
          // Redirect to needed page 
          redirect("needed url"); 
         } 
        }); 
        initWidget(uiBinder.createAndBindUi(this)); 
        } 
    
        public static native void redirect(String url)/*-{ 
        $wnd.location = url; 
        }-*/; 
    }