我有一个模板,我用:
渲染<g:render template="recordInfo" />
在我的主要布局中。 (布局/ main.gsp)。
这是一个模板,我的一些观点需要和一些观点不适用。
对于不需要该模板的视图,我在顶级视图目录(/ grails-app / views)中放置了一个名称为空的文件。如grails文档中所述:
Without the leading '/' it will be first be resolved relative to the
current controller's view directory then, failing that, the top level
views directory.
对于在自己的view-directory中具有模板文件的视图(例如/ grails-app / views / address),它可以正常工作。但它并不起作用,Grails应该在/ grails-app / views级别搜索模板。
我是否理解文档中的错误或我的代码中是否有错误?
我的文件/目录结构如下:
...
MyApp/grails-app/views/_recordInfo.gsp
MyApp/grails-app/views/address/_form.gsp
MyApp/grails-app/views/address/ ...
MyApp/grails-app/views/address/_recordInfo.gsp
MyApp/grails-app/views/contact/_form.gsp
MyApp/grails-app/views/contact/ ...
...
地址视图需要一个自定义的_recordInfo模板,联系人视图不需要它(因此我认为grails会选择MyApp / grails-app / views目录中的那个...)< / p>