grails - Grails-网址中的%252F

标签 grails

我正在使用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/

相关文章:

Grails 2.3 - 新示例项目不工作

grails - 更新或更改Grails中的用户数据表单

mongodb - 用于 MongoDB 的 Grails 3 和 FORM 6 - 重复键错误

grails - 在新标签页中打开 View -Grails

grails - 用插件创建ICal,好像只能下载,不知道怎么附加发送邮件功能

grails - 测试 Controller 响应时出错。回复未更新

unit-testing - PageRenderer 在单元测试期间返回空对象

html - Grails渲染标记和message.properties

javascript - Groovy 呈现为 JSON java.sql.timestamp 在 JavaScript 中不显示毫秒数

grails - grails/gorm消息捆绑问题