我正在使用Spring Security插件登录应用程序。 Spring Security具有用于登录的默认auth.gsp
页面。我创建了自己的auth.gsp
页面以添加其他内容auth.gsp
<g:form action='${postUrl.encodeAsURL()}' method='POST' id='loginForm' autocomplete='off' class="login-form">
<g:textField class="field" name="username" value="${params.userName}"/>
<g:passwordField class="field" name="password"/>
<button>login</button>
<p class="message"><a href="elb/index">Forgot Password?</a></p>
<p class="message"><a id="next" name="next" href="#">Have Invitation Code?</a></p>
</g:form>
问题在于
${postUrl}
在网址中包含%252F
。这是完整的网址:http://localhost:8080/login/%252Flogin%252Fauthenticate/loginForm
。我已经尝试了在stackoverflow上给出的所有可能答案,但是没有任何效果。
最佳答案
尝试使用
<g:form url='${postUrl}' method='POST' id='loginForm' autocomplete='off' class="login-form">
<g:textField class="field" name="username" value="${params.userName}"/>
<g:passwordField class="field" name="password"/>
<button>login</button>
<p class="message"><a href="elb/index">Forgot Password?</a></p>
<p class="message"><a id="next" name="next" href="#">Have Invitation Code?</a></p>
</g:form>
设置完整网址时,请使用“url”属性。如果使用“ Action ”,则必须设置 Action 名称。
也不要使用encodeAsURL()。 encodeAsURL的意思是,您要转义特殊字符,例如'/','?'被“%..”实体替换的实体。
关于grails - Grails-网址中的%252F,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36578522/