为 Grails 脚手架禁用 sitemesh?
如何禁用支持脚手架的控制器的模板和 sitemesh?我想在这里显示完整的脚手架,我的主模板与此有关。
How do I disable templating and sitemesh for scaffold-enabled controllers? I want to display the full scaffold here, and my main template is screwing with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您想重命名脚手架视图中使用的布局名称。完成后,
您就拥有了生成的脚手架页面的模板(当您执行
grailsgenerate-all*
时,您可能已经使用过该模板)。在新文件夹 src/templates/scaffolding/*.gsp 中,将布局名称更改为类似于 generatedMain 的名称。我想您知道,但为了确定:现在恢复原始的
main.gsp
并将其重命名为generateMain.gsp
。然后使用 grailsgenerate-all * 重新生成脚手架视图。至少,这是我在几个项目中所做的方式;-)
I think you want to rename the layout name used from the scaffolded views. After you did
you have the template of the generated scaffolded pages (which you might have used, when you did
grails generate-all *
). In the new foldersrc/templates/scaffolding/*.gsp
change the layout name to something likegeneratedMain
. I guess you know, but just to be sure:Now restore the orginal
main.gsp
and rename it togeneratedMain.gsp
. Then regenerate your scaffolded views usinggrails generate-all *
.At least, this is the way I did it in a couple of projects ;-)
更改非脚手架视图以使用“foo”布局,方法是在每个(非脚手架)GSP 的
中明确声明它,或者将以下内容添加到
Config .groovy
此时,只有脚手架页面将使用“主”布局,您可以通过将其更改为以下内容来有效地使其成为“空”布局:
Change your non-scaffolded views to use a 'foo' layout, either by stating it explicitly in the
<head>
of each (non-scaffolded) GSP or by adding the following toConfig.groovy
At this point, only the scaffolded pages will be using the 'main' layout and you can effectively make this an "empty" layout by changing it to something like:
不要使用
main.gsp
作为主布局。相反,使用yourlayout.gsp
,在 GSP 中手动设置它,然后使用的 sitemesh 将成为默认值,这就是脚手架所需的。Don't use
main.gsp
as your main layout. Rather, useyourlayout.gsp
, manually set it in your GSPs, and then the sitemesh used will be the default, which is what you need for the scaffold.