Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Boot 2.0静态内容不使用上下文路径_Spring_Spring Boot_War_Contextpath - Fatal编程技术网

Spring Boot 2.0静态内容不使用上下文路径

Spring Boot 2.0静态内容不使用上下文路径,spring,spring-boot,war,contextpath,Spring,Spring Boot,War,Contextpath,我有一个SpringBoot2.0应用程序,我正试图将其部署为WAR文件。这意味着它将有一个自定义上下文路径。为了作为Java应用程序进行测试,我添加了 server.servlet.context-path=/MyApplication 到application.properties。在我的index.html(位于src/main/resources/static中)中,我尝试使用如下内容包含Javascript: <script src="dist/main.js"</scr

我有一个SpringBoot2.0应用程序,我正试图将其部署为WAR文件。这意味着它将有一个自定义上下文路径。为了作为Java应用程序进行测试,我添加了

server.servlet.context-path=/MyApplication
到application.properties。在我的index.html(位于src/main/resources/static中)中,我尝试使用如下内容包含Javascript:

<script src="dist/main.js"</script>

我刚想出来。在我的index.html中,我设置了一个基本href:

<base href="/">

我将index.html转换为JSP,并使用JSP标记设置基本href:

<base href='<c:url value="/" />'>

我刚想出来。在我的index.html中,我设置了一个基本href:

<base href="/">

我将index.html转换为JSP,并使用JSP标记设置基本href:

<base href='<c:url value="/" />'>

将index.html中的
修改为以下内容:

这将尝试从指定的上下文路径加载所有脚本,并为我解决了问题。

将index.html中的
修改为以下内容

这将尝试从指定的上下文路径加载所有脚本,并为我解决了这个问题