有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

我有这个项目结构: enter image description here

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

但是我需要从这个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

如果我移动门户/索引。html到资源-索引。html从http://localhost:8080/ui/index正确加载

如何配置应用程序以加载索引。来自webapp文件夹的html


共 (0) 个答案