java Spring引导在哪里需要JSP
我做了this教程,将一个旧的jsp应用程序迁移到spring boot。但我用的不是maven而是gradle。在IntelliJ Idea中,一切都是明摆着的。 现在我想为这个应用程序制作一个docker容器,因此我使用了jib gradle插件。但是当我运行这个docker容器时,我得到了一个错误“出现了一个意外错误(type=notfound,status=404)。/WEB-INF/jsp/index.jsp”。实际上,docker容器中缺少/WEB-INF/jsp目录。所以我通过jib参数添加了它,但仍然没有找到它。那么Spring在哪里查找这些文件呢?我必须把文件放在哪里?是否可以使用属性更改此目录
# 1 楼答案
经过数小时的调试,我发现可以通过设置ServletWebServerFactory的文档根来设置jsp文件的目录
这为我解决了问题
# 2 楼答案
春天说
你也可以在这个SO question中获得更多信息
我查看了您提供的教程链接,发现项目打包是
jar
,而不是war
。可能需要通过应用Gradle WAR插件将项目转换为war
项目