首页 > 解决方案 > grails无法从插件中找到视图

问题描述

我正在尝试编写一个可以查看文件的 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 我不知道这是否可能是此版本中的错误或什么。

标签: grailsgrails-plugingsp

解决方案


It seems that I should have had

plugin: 'filexplorer'

instead of

plugin: 'fileExplorer'

I could have sworn I tried this already. I guess the thing is it can be confusing which name to use where as far as plugins, as in the build.gradle name, the name in the *Plugin.groovy, the name in settings.gradle, the package name etc. Anyway, somehow I screwed up.


推荐阅读