【问题标题】:Redirect to GSP failing重定向到 GSP 失败
【发布时间】:2016-10-06 07:51:16
【问题描述】:

我正在使用 grails 2.4.5

在我的 grails-app/views 目录中,我有一个名为“test.gsp”的简单文件。它的内容是微不足道的 GSP/HTML:

<html>
    <head>
            <meta name="layout" content="main" />
            <title>TEST</title>
            <style>
            </style>
    </head>
    <body>
            <h1>TEST</h1>
    </body>
</html>

在控制器动作中,我有一行:

redirect(uri:"/test.gsp");

但是每当到达这条线时,grails 就会将我发送到 404 处理程序。

我尝试启用 UrlMapping 日志记录,它显示:

DEBUG mapping.DefaultUrlMappingsHolder  - Matched URI [/test.gsp] with pattern [/(*)/(*)?/(*)?(.(*))?], adding to posibilities

我确信我以前在 Grails 中也有过这项工作。我错过了什么傻事?

【问题讨论】:

    标签: redirect grails uri


    【解决方案1】:

    您应该渲染一个视图,而不是尝试重定向到(可能未映射)uri。 试试:

    render(view: "test")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      • 1970-01-01
      • 1970-01-01
      • 2011-03-29
      • 2010-12-02
      • 2012-12-27
      • 2020-06-30
      相关资源
      最近更新 更多