springboot中编译成war出现Failed to load resource: the server responded with a status of 404 ()的问题

我用的eclipse,在代码中直接springboot运行的时候是没出现这个bug的,等到发布为war的时候,出现了报错。
其实原因就是link静态资源没对。
我用的是thymeleaf,但是之前图方便,就直接类似这么引用了

<link href="../js.bootstrap.js"/>

这在调试中没出问题,但是部署发布就bug了,解决也容易,就老老实实写呗。

<link th:href="@{/js/bootstrap.js}" />

ok。
事后进一步分析和解决,点这

猜你喜欢

转载自blog.csdn.net/baidu_31788709/article/details/104396016