Sparkjava - 将 webapp 文件夹设置为静态资源/模板的文件夹

问题描述

我有这个项目结构:

enter image description here

如果我打开这个网址:http://localhost:8080/portal/index.html 浏览器会正确加载我的 index.html(因为它位于 portal 文件夹下的根文件webbapp 中)>

但是我需要从这个 URL 加载这个页面http://localhost:8080/ui/index。我添加了这条路线:

get("/ui/index",(req,res) -> {
    Map<String,Object> model = new HashMap<>();
    return new VeLocityTemplateEngine().render(
               new ModelAndView(model,"portal/index.html")
           );
});

但我收到此错误500 Internal Server Error

如果我将 portal/index.html 移动到资源 - index.html 从 http://localhost:8080/ui/index 正确加载。

如何配置我的应用程序以从 webapp 文件夹加载 index.html?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)