我目前正在使用Spring Boot和Spring Social来允许人们使用Facebook,Twitter或LinkedIn在我的项目中登录,该项目基于已经存在的Spring项目 -
我希望能够在我的项目中提供静态内容(CSS,JS,Images) . 我也使用Thymeleaf模拟我的观点 . 问题是,当我运行项目时,Spring无法找到静态内容 . 我在其他网站上进行了研究,发现了一篇文章 -
http://www.logicbig.com/tutorials/spring-framework/spring-boot/boot-serve-static/
如果您的静态内容位于/ resources文件夹中,那么Spring就能找到它 . 我看过的其他文章和项目是 -
这是我的文件树的图片以及文件所在的位置 .
这是signin.html页面
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/index.css" rel="stylesheet" />
</head>
<body>
<form th:action="@{/signin/facebook}" method="POST">
<button id="facebookloginelementbutton" type="submit" class="loginelementbutton">Login with <i class="fa fa-facebook-square"></i></button>
<input type="hidden" name="scope" value="email,publish_stream,offline_access" />
</form>
<script src="js/index.js"></script>
</body>
</html>
如果您需要查看更多文件或我是否会出现这种错误,请告诉我!
提前致谢,
亚当
1 回答
你需要有如下的项目结构,资源文件夹里面的静态文件夹,然后你可以在静态文件夹里面
css, images, js etc
:然后在代码中引用CSS,如:
和javascripts喜欢: