问题描述
我正在尝试编写一个可以查看文件的 grails 插件。实际上,我只是想将这里的这个升级... https://github.com/intelligrape/File-Viewer-Grails-Plugin 到 grails4,并让它在我的应用程序中运行。
无论如何,在应用程序中运行后,我访问 http://localhost:8080/file/index 并收到此错误:
URI
/file/index
Class
javax.servlet.servletexception
Message
Could not resolve view with name '/plugins/file-explorer-0.1/file/fileList' in servlet with name 'grailsdispatcherServlet'
当控制器执行此操作时会发生这种情况...
def index(String filePath) {
Map model = [locations: fileLocations.locations]
// blah blah
render(view: "/file/fileList",model: model,plugin: 'fileExplorer')
}
render() 方法被调用(我在调试器中检查过)。我也尝试删除 plugin: 参数,但没有任何区别。
现在,如果我将插件作为独立应用程序运行(通过转到该文件夹并运行“grails run-app”,那么它会按预期工作,并且 http://localhost:8080/file/index 呈现视图正如人们所期望的那样。
这一切让我相信该插件基本上可以工作并安装到我的应用程序中,除了视图组件,无论出于何种原因无法从插件中找到视图。
如果您想知道源文件是什么样子,基本上就是您在此处看到的内容:... https://github.com/intelligrape/File-Viewer-Grails-Plugin 除了我已将其从 FileViewer 重命名为 FileExplorer。
我正在使用 grails 4.1.0.M5 我不知道它是否可能是这个版本中的错误或什么。
解决方法
看来我应该有
plugin: 'filexplorer'
代替
plugin: 'fileExplorer'
我可以发誓我已经试过了。我想问题是就插件而言,使用哪个名称可能会令人困惑,例如 build.gradle 名称、*Plugin.groovy 中的名称、settings.gradle 中的名称、包名称等。无论如何,不知怎么的,我搞砸了。