【发布时间】:2020-04-08 10:59:20
【问题描述】:
我使用以下代码创建了一个新的 grails 应用程序
grails create-app myapp --profile=rest-api
我修改了ApplicationController并添加了namespace,如下:
class ApplicationController implements PluginManagerAware {
/** The Namespace for the version of the API, see http://docs.grails.org/latest/guide/REST.html#versioningResources */
static namespace = "v1"
GrailsApplication grailsApplication
GrailsPluginManager pluginManager
def index() {
[grailsApplication: grailsApplication, pluginManager: pluginManager]
}
}
views/application/ 目录下存在一个index.gson 文件。
我使用grails run-app 运行此设置并将我的浏览器指向http://localhost:8080
它抛出以下异常:
<=======2020-04-08 16:01:31.616 ERROR --- [nio-8080-exec-1] .a.c.c.C.[.[.[.[grailsDispatcherServlet] : Servlet.service() for servlet [grailsDispatcherServlet] in context with path [] threw exception [Could not resolve view with name 'index' in servlet with name 'grailsDispatcherServlet'] with root cause
但是,如果我修改控制器代码并使用 render,一切正常。
render(view:'index',model: [grailsApplication: grailsApplication, pluginManager: pluginManager])
grails -v 的输出 Grails 版本:4.0.2
JVM版本:1.8.0_171 操作系统:macOS High Sierra
【问题讨论】:
标签: grails grails-plugin grails-4