[英]Static content not loading from spring boot war in jboss server
i have placed the static content such as css, js, images in static folder under resources and all the html files in templates folder. 但是,當我建立戰爭並將其部署在 jboss 上時。 html 已加載,但 static 內容未加載,並且在內置 tomcat 服務器中也可以正常工作。
url to access the war pages: IP:8080/warname/login
when i inspect in console of chrome i get url of js, css as IP:8080/js/jsfile.js
or IP:8080/css/abc.css
.
這是我的項目結構圖片
您在 src 或 href 中引用 static 內容,例如 /js 但這在部署為 WAR 文件時不起作用,因為在應用程序服務器中將添加上下文根。 (在您的情況下為戰名)
您必須使用 Thymleaf 語法,例如
<script type="text/javascript" th:src="@{/js/searchOP.js}"></script>
請查看文檔以獲取更多信息:https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.