I am currently using Spring Boot and Spring Social to allow people to log in using Facebook, Twitter, or LinkedIn, within my project, which is based on an already existing Spring project -
I want to be able to serve static content (CSS, JS, Images) within my project. I am also using Thymeleaf to template my views. The problem is that when I run the project, Spring can't find the static content. I have researched on other websites and found an article -
http://www.logicbig.com/tutorials/spring-framework/spring-boot/boot-serve-static/
that said that if your static content was in a /resources folder, Spring would be able to find it. Other articles and projects that I've looked at are -
Here is a picture of my file tree and where the files are located.
Here is the signin.html page
<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>
If you need to see more files or if I am going about this wrong, please tell me!
Thanks in advance,
Adam
You need to have project structure like below, static folder inside resources folder, then inside static folder you can have css, images, js etc
:
Then CSS is referred in the code like:
<link href="/assets/css/dashboard.css" rel="stylesheet" />
and javascripts like:
<script src="/assets/js/project_angular.js"></script>