【问题标题】:Calling a .gsp page调用 .gsp 页面
【发布时间】:2014-06-23 14:42:55
【问题描述】:

我制作了 index.gsp 的副本,名为 index_1.gsp,我喜欢从 html 页面调用。

因为我确实知道如何从 html 页面调用它,所以我尝试使用以下命令从控制器调用 index_1.gsp:redirect(uri: "/index_1.gsp"),但失败了。

如果您帮助我从 html 页面或控制器调用它,我将不胜感激。 谢谢

【问题讨论】:

  • 您不能从 HTML 页面调用 GSP 页面。框架不支持它,它没有意义。

标签: grails gsp


【解决方案1】:

您不能从 HTML 页面调用 GSP。这没有意义。

如果你想从控制器渲染视图,你可以这样做......

class SomeController {
    def someAction() {
        // this will render grails-app/views/some/index_1.gsp
        render view: 'index_1'
    }
}

【讨论】:

  • 如果 GSP 在 grails-app/views/ 而不是 grails-app/views/<some controller name>/ 中,那么您可以使用 render view: '/index_1' 之类的内容进行渲染。
  • 非常感谢您的及时回答。当我运行建议的解决方案时,我得到“请求的资源不可用,对于 index_1.jsp(gsp 更改为 jsp)。
  • 很高兴能帮上忙。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-11
  • 1970-01-01
  • 2014-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多