基于本教程:
http://spring.io/guides/gs/serving-web-content/ http://spring.io/guides/gs/serving-web-content/
我可以使用百里香来提供该地点的景观
/src/main/resources/templates/
但是,我必须将静态网页内容(css、js)放在另一个位置:
/src/main/webapp/resources
并链接资源你好.html像那样:
<link href="resources/hello.css" />
<script src="resources/hello.js"></script>
目录结构为:
└── src
└── main
└── java
└── hello.java
└──resources
└──templates
└──hello.html
└──webapp
└──resources
└──hello.js
└──hello.css
问题是当我运行网络服务器时,静态文件的链接是有效的。但如果我打开html离线模式下的文件,链接已损坏。
我可以将静态资源从
/src/main/webapp/resources
to:
/src/main/resources/templates/resources
新的目录结构如下:
└── src
└── main
└── java
└── hello.java
└──resources
└──templates
└──hello.html
└──resources
└──hello.js
└──hello.css
我尝试过但不起作用。
Try src/main/resources/static
(or src/main/resources/public
or src/main/resources/resources
)。所有这些都是由 Spring Boot 自动配置注册的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)