【发布时间】:2018-10-01 08:20:26
【问题描述】:
我有一个 Spring Boot 2.0 应用程序,我正在尝试将其部署为 WAR 文件。这意味着它将具有自定义上下文路径。为了测试我添加的 Java 应用程序
server.servlet.context-path=/MyApplication
到 application.properties。在我的 index.html(位于 src/main/resources/static)中,我尝试使用类似这样的方式包含 Javascript:
<script src="dist/main.js"</script>
无论我是否使用上下文路径,它总是尝试从http://localhost:8080/dist/main.js 加载文件,完全忽略我指定的上下文路径。如果我尝试将我的应用程序部署为 WAR,情况也是如此。该文件确实位于http://localhost:8080/MyApplication/dist/main.js。
我需要在我的配置中进行哪些更改以使 Spring Boot 在提供静态内容时使用上下文路径?
【问题讨论】:
标签: spring spring-boot war contextpath