我有一个名为TestPlugin的插件,该插件在名为grails-app/views_test-include.gsp中提供了GSP包含。我正在将TestPlugin导入TestApp并尝试以如下方式呈现它:

<g:render template="_test-include" plugin="${applicationContext.getBean('pluginManager').getGrailsPlugin('testPlugin')}"/>

我也尝试过这个:
<g:render template="_test-include" plugin="testPlugin"/>

两者都会导致引发异常。这是Grails的错误报告:
Message: Error mapping onto view [/index]: Error processing GroovyPageView: Error executing tag <g:render>: null
    Line | Method
->> 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    617 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . in java.lang.Thread
Caused by GroovyPagesException: Error processing GroovyPageView: Error executing tag <g:render>: null
->>  527 | runWorker in C:\temp\grails-test\test-app\grails-app\views\index.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by GrailsTagException: Error executing tag <g:render>: null
->>  113 | doCall    in C:/temp/grails-test/test-app/grails-app/views/index.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by NullPointerException: null
->>  936 | get       in java.util.concurrent.ConcurrentHashMap
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    141 | getValue  in grails.util.CacheEntry
|     81 | getValue  in     ''
|     58 | doCall    in C__temp_grails_test_test_app_grails_app_views_index_gsp$_run_closure2
|     70 | run . . . in C__temp_grails_test_test_app_grails_app_views_index_gsp
|   1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

最佳答案

不要以_开头呈现模板。

这应该工作:

<g:render template="/test-include" plugin="testPlugin"/>

关于java - Grails无法呈现插件中包含的GSP,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26266326/

10-14 10:36