问题描述
我想从我的 spark-java 服务器返回 index.html。此页面位于:
src/main/webapp/portal/v1/index.html
我添加了这条路线:
get("/portal/v1/*",(req,res) -> {
Map < String,Object > model = new HashMap <> ();
return new VeLocityTemplateEngine().render(
new ModelAndView(model,"/portal/v1/index.html")
);
});
当我在浏览器中打开 URL 时:http://localhost:8080/portal/v1/
我收到这个错误:500 Internal Server Error
在日志中,我看到了这个堆栈跟踪:
29-Mar-2021 11:58:22.038 SEVERE [http-nio-8080-exec-9] org.apache.veLocity.runtime.log.JdkLogChute.log ResourceManager : unable to find resource '/portal/v1/index.html' in any resource loader.
但如果我的页面位于:src/main/resources/portal/v1/index/html
下,此代码可以正常工作并返回 index.html
。
我尝试像这样更改静态资源文件夹:
externalStaticFileLocation("src/main/webapp");
externalStaticFileLocation("/src/main/webapp");
externalStaticFileLocation("src/main/webapp/");
externalStaticFileLocation("/src/main/webapp/");
但这无济于事。
如何从 index.html
文件夹而不是 webapp
文件夹加载 resources
?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)