【问题标题】:grails can't find view from plugingrails无法从插件中找到视图
【发布时间】:2021-06-11 23:42:27
【问题描述】:

我正在尝试编写一个可以查看文件的 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 不知道是不是这个版本的bug还是什么。

【问题讨论】:

    标签: grails grails-plugin gsp


    【解决方案1】:

    看来我应该有

    plugin: 'filexplorer'
    

    而不是

    plugin: 'fileExplorer'
    

    我可以发誓我已经尝试过了。我想问题是它可能会混淆在插件中使用哪个名称,如 build.gradle 名称、*Plugin.groovy 中的名称、settings.gradle 中的名称、包名称等。无论如何,不知怎的,我搞砸了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 2013-01-30
      相关资源
      最近更新 更多