2016-08-02 124 views
2

我已經在我的application.yml中聲明瞭Spring Security作爲依賴項,並且在運行我的應用程序時默認登錄表單按預期工作。我想對錶單進行樣式設計,以便我的應用程序無縫連接。自定義Spring Security 3.1.1在Grails 3中登錄表單

在視圖/ AUTH我有auth.gsp其中包含下面的代碼:

<form method="POST" action="${resource(file: 'j_spring_security_check')}"> 
    <table> 
     <tr> 
      <td>Username:</td><td><g:textField name="j_username"/></td> 
     </tr> 
     <tr> 
      <td>Password:</td><td><input name="j_password" type="password"/></td> 
     </tr> 
     <tr> 
      <td colspan="2"><g:submitButton name="login" value="Login"/></td> 
     </tr> 

    </table> 
</form> 

提交表單沒有任何反應時,卻出現預期這種形式。我假設這是因爲{resource(file: 'j_spring_security_check')}不是它應該進行的操作。我從here得到了這段代碼,我相信這是用Grails 2編寫的。任何想法正確的行動是什麼?

回答

3

以下是工作定製的登錄表單:

<form method="POST" action="${resource(file: '/login/authenticate')}" class="form-signin"> 
    <h2 class="form-signin-heading text-center">Login</h2> 

    <input type="text" class="form-control" name="username" placeholder="Username"/> 
    <input type="password" class="form-control" name="password" placeholder="Password"/> 

    <label class="checkbox text-center"> 
     <input type="checkbox" value="remember-me" id="rememberMe" name="remember-me"> Remember me 
    </label> 

    <button class="btn btn-lg btn-default btn-block" type="submit">Login</button> 
    </form> 

要注意的主要事項是:現在現在

  • j_spring_security_check/login/authenticate
  • j_username現在username
  • j_passwordpassword

文檔春季安全3,它用於Grails的3 here

0

我很震驚地發現,六年前的一篇博文並不是100%正確的。也許你會有更好的運氣閱讀the documentation,特別是「3.0版本的新變化」部分。

+0

有點offtopic,但你可以請發表評論http://stackoverflow.com/questions/38175154/which-plugin-module-of -spring-sec-oauth-should-used-in-grails-3-x? – injecteer

相關問題