Вопрос

With Grails, is it possible to get the name of the view that is being rendered while in the layout GSP file? I'd like to change one minor thing in the layout file depending on which view is going to be rendered.

Это было полезно?

Решение

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.

Другие советы

The name of the view is normally the same as the action that has just been executed (e.g. show action normally renders the show.gsp view) - if this is the case in your view, then you can get it in your layout gsp using ${actionName}.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top