我在尝试渲染GSP(使用Grails 2.3.6)时得到以下错误:
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Template not found for name [/shared/mymenu] and path [/shared/_mymenu.gsp]
...long stacktrace omitted
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
/shared/_mymenu.gsp
内部:
<g:render template="/shared/mmenustub" model="${['root':appmenu]}">
</g:render>
我错过了什么吗?也许是plugin
属性之类的?如果是,我错过了什么,它的价值应该是什么?
globalmenu
标签库定义如下:
class GlobalMenuTagLib {
def globalmenu = { attrs, body ->
List<NavigationScheme> allNavigationSchemes = navigationSchemeService.listAll()
def mapped = allNavigationSchemes.groupBy { menu -> menu.appreference }
def registeredApps = registerInfoService.listAllActive()
def activePage = attrs.activepage
def tempName = attrs.tempName?:'anothermenu'
out << render(template: "/shared/$tempName", model:[navscheme: mapped, regApps: registeredApps, activepage:activePage])
}
}
无法找到/shared/_mymenu。gsp文件。如果这个文件存在于一个插件中,那么你需要在渲染方法中使用"plugin"参数引用它,以便它知道在哪里搜索该文件。
out << render(template: "/shared/$tempName", model:[navscheme: mapped, regApps: registeredApps, activepage:activePage], plugin: "myplugin")
其中"myplugin"为插件名