请记住,Cookie不是使用Spring Security和基于JWT令牌的身份验证创建的
我想在我的Spring Boot MVC项目中添加记住我的功能。我看过一些教程,我根据它们应用了更改,但没有一个是有效的。我甚至下载了他们自己的源代码并在我的系统中运行,但“记住我”cookie既不是在我的项目中创建的,也不是在他们的项目中创建的。所以我没能抓住这个问题。请有人检查一下我的代码,帮我找到它。 以下是POM.xml文件:请记住,Cookie不是使用Spring Security和基于JWT令牌的身份验证创建的,spring,spring-boot,spring-mvc,spring-security,remember-me,Spring,Spring Boot,Spring Mvc,Spring Security,Remember Me,我想在我的Spring Boot MVC项目中添加记住我的功能。我看过一些教程,我根据它们应用了更改,但没有一个是有效的。我甚至下载了他们自己的源代码并在我的系统中运行,但“记住我”cookie既不是在我的项目中创建的,也不是在他们的项目中创建的。所以我没能抓住这个问题。请有人检查一下我的代码,帮我找到它。 以下是POM.xml文件: <?xml version="1.0" encoding="UTF-8"?> <project xmln
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.10.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.project.art-project</groupId>
<artifactId>art-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ArtProject</name>
<description>Art project website</description>
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<dependencies>
<!-- STARTER-WEB -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- STRTER-SECURITY -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- JASPER -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- STRIPE -->
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>10.12.1</version>
</dependency>
<!-- DEVTOOLS -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- JSTL -->
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- MYSQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- H2 DATABASE -->
<!-- dependencies for h2 database for temporary use -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- TWILIO -->
<dependency>
<groupId>com.twilio.sdk</groupId>
<artifactId>twilio</artifactId>
<version>7.55.2</version>
</dependency>
<!-- AUTHY-JAVA -->
<!-- https://mvnrepository.com/artifact/com.authy/authy-java -->
<dependency>
<groupId>com.authy</groupId>
<artifactId>authy-java</artifactId>
<version>1.2.0</version>
<scope>runtime</scope>
</dependency>
<!-- BOOTSTRAP -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.6</version>
</dependency>
<!-- BOOTSTRAP-DATEPICKER -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.0.1</version>
</dependency>
<!-- JQUERY -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.9.1</version>
</dependency>
<!-- STARTER-TEST -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
这是我的HTML页面:
<form
class="form-container col-xl-4 col-lg-4 col-md-6 col-sm-8 col-12"
method="POST" action="login">
<div class="form-group">
<span class="position-absolute user-position"><img
src="icons/user.png"></span>
<input type="text" name="mobile"
class="form-control user w-100 mx-auto rounded-0 pl-4"
placeholder="Mobile" />
<div id="mobileValid"></div>
</div>
<div class="form-group">
<span class="position-absolute lock-position"><img
src="icons/lock.png"></span>
<input type="password" name="password"
class="form-control password w-100 mx-auto rounded-0 pl-4"
placeholder="Password" required="true" />
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" name="remember">
<small> <label
class="form-check-label color-white ml-2 mt-2" for="remember-me"> Remember
Me</label> <a href=# class="forgot-password float-right ml-2 mt-2">Forgot
Password?</a>
</small>
</div>
</form>
记得
我
我已经用了两天的时间,但没有找到正确的答案。有人能给我引路吗
<form
class="form-container col-xl-4 col-lg-4 col-md-6 col-sm-8 col-12"
method="POST" action="login">
<div class="form-group">
<span class="position-absolute user-position"><img
src="icons/user.png"></span>
<input type="text" name="mobile"
class="form-control user w-100 mx-auto rounded-0 pl-4"
placeholder="Mobile" />
<div id="mobileValid"></div>
</div>
<div class="form-group">
<span class="position-absolute lock-position"><img
src="icons/lock.png"></span>
<input type="password" name="password"
class="form-control password w-100 mx-auto rounded-0 pl-4"
placeholder="Password" required="true" />
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" name="remember">
<small> <label
class="form-check-label color-white ml-2 mt-2" for="remember-me"> Remember
Me</label> <a href=# class="forgot-password float-right ml-2 mt-2">Forgot
Password?</a>
</small>
</div>
</form>