This is my login.html file(view)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>The Login Page</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="application/x-javascript" th:inline="javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:600italic,400,300,600,700' media="screen" rel='stylesheet' type='text/css' />
<link rel="stylesheet" th:href="@{/css/style.css}" media="screen" href="../public/css/style.css" />
</head>
<body>
<!-- start-main -->
<div class="container-fluid" style="border: 1px solid red;">
<!--start of the login form-->
<div class="login-form">
<div class="head">
<img th:src ="@{/images/mem2.jpg}" src="../public/images/mem2.jpg" alt=""/>
</div>
<form action="#" method="post" th:action="@{/login}" th:object="${user}">
<li>
<input type="text" class="text" name="username" placeholder="Username" th:field="*{username}" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Username';}" /><a href="#" class=" icon user" ></a>
<p th:if="${#fields.hasErrors('username')}" th:errors="*{username}">Username Error</p>
</li>
<li>
<input type="password" name="password" placeholder="Password" th:field="*{password}" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Password';}" /><a href="#" class=" icon lock"></a>
<p th:if="${#fields.hasErrors('password')}" th:errors="*{password}">Password Error</p>
</li>
<div class="p-container">
<label class="checkbox"><input type="checkbox" name="checkbox" checked="checked" /><i></i>Remember Me</label>
<input type="submit" value="SIGN IN" />
<div class="clear"> </div>
</div>
</form>
</div>
<!--//End-login-form-->
<!--start-copyright-->
<div class="copy-right">
<p th:include="footer :: footer"></p>
</div>
<!--//end-copyright-->
</div>
</body>
</html>
In this login.html i use thymeleaf to reference to css,js and images
Below is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.social.manager</groupId>
<artifactId>Social-Manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SocialManagement</name>
<description>Social Management App</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-facebook</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-linkedin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-twitter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Please I need assistance I have gone through the other post on this subject but none of them seem to work.
My css files are placed under src/main/resources/public
src/main/resources/pubic/css
src/main/resources/public/js
src/main/resources/public/images
And my template files are located at:
src/main/resources/templates
If there is none resource handler processing those paths, the @{/css/style.css}
will get the file that you have in src/main/webapp/css/style.css
of you source code; it is not the same folder structure that you final war package.
The default maven war packing configuration will put the src/main/resources
content into WEB-INF/classes/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.