简体   繁体   English

Grails:在Layout GSP中获取视图名称

[英]Grails: Get the View name in the Layout GSP

With Grails, is it possible to get the name of the view that is being rendered while in the layout GSP file? 使用Grails,是否可以获取在布局GSP文件中呈现的视图的名称? I'd like to change one minor thing in the layout file depending on which view is going to be rendered. 我想根据要渲染的视图更改布局文件中的一件小事。

视图的名称通常与刚刚执行的动作相同(例如, show action通常会呈现show.gsp视图)-如果您的视图属于这种情况,则可以使用${actionName}在布局gsp中获取它。 ${actionName}

If found this to be rather difficult to determine. 如果发现这一点很难确定。 It's easy if you use conventions, but you can always explicitly render any view you want. 如果使用约定很容易,但是您始终可以显式呈现所需的任何视图。 See the code in How to detect which view file has been rendered in grails for how to determine this in a filter. 有关如何在过滤器中确定该视图的信息,请参见如何检测已在grails中呈现的视图文件中的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM