如何将布局和模板应用于其他控制器文件夹?

时间:2014-04-28 07:29:05

标签: grails gsp

我想将layouts / main.gsp布局应用于用户/登录页面。 我的main.gsp引用了其他css并引用了模板:

</head>

<body>

<g:render template = "templates/headerTop" contextPath = "/"></g:render>

<g:render template = "templates/menuHeader" contextPath = "/"></g:render>
<g:layoutBody/>
<g:render template="templates/footer" contextPath = "/"></g:render>

</body>

但是,当我运行应用程序并进入登录时,单击它表示找不到模板路径。我了解,因为登录是在&#39;用户&#39;文件夹,所以它无法搜索路径。 问题是:如何将布局应用到我的登录页面。

1 个答案:

答案 0 :(得分:1)

您需要指定模板的绝对路径:

   <g:render template = "/templates/headerTop" contextPath = "/"></g:render>