1

Grails Spring Security Plugin から生成されたログイン ビューのログイン フォームを、layouts/main.gsp のメイン レイアウトに配置したいと考えています。コピーしたばかりですが、フォームデータを渡すためのコントローラーが使用できないため、機能しません。フォームコードは次のようになります。

<form action='${postUrl}' method='POST' id='loginForm' class='cssform' autocomplete='off'>
      <p>
        <label for='username'><g:message code="springSecurity.login.username.label"/>:</label>
        <input type='text' class='text_' name='j_username' id='username'/>
      </p>
      <p>
        <label for='password'><g:message code="springSecurity.login.password.label"/>:</label>
        <input type='password' class='text_' name='j_password' id='password'/>
      </p>
      <p id="remember_me_holder">
        <input type='checkbox' class='chk' name='${rememberMeParameter}' id='remember_me' <g:if test='${hasCookie}'>checked='checked'</g:if>/>
        <label for='remember_me'><g:message code="springSecurity.login.remember.me.label"/></label>
      </p>
      <p><input type='submit' id="submit" value='${message(code: "springSecurity.login.button")}'/></p>
    </form>

フォームコードをログイン認証アクションに送信するには、このコードをどのように変更すればよいですか?

ありがとう。

4

1 に答える 1

2

あなたの質問は、フォームアクションに何を使用するかです。postUrlconfig のプロパティと同じである必要がgrails.plugins.springsecurity.apf.filterProcessesUrlあり、デフォルトでは/j_spring_security_check.

この値を変更しなかった場合は、/j_spring_security_check代わりに を使用できます${postUrl}

Spring Securty プラグインには、この URL を処理し、ユーザーを承認する特別なフィルターがあります。次のステップは構成によって異なりますが、私の記憶が正しければ、デフォルトでユーザーは にリダイレクトされます/

http://grails-plugins.github.io/grails-spring-security-core/guide/urlProperties.htmlで構成オプションを参照してください。

于 2012-06-09T12:03:43.310 に答える