2016-08-02 89 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

相关问题