标签:inpu name figure type tps pos prot security ted
引入POM
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>5.0.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>5.0.3.RELEASE</version> </dependency>
html:
<input type="checkbox" name="remember-me" checked value="true">
配置:
@Autowired private DataSource dataSource;
@Autowired private UserDetailService userDetailsService; @Override protected void configure(HttpSecurity http) throws Exception { http.rememberMe() .tokenRepository(persistentTokenRepository()) .userDetailsService(userDetailsService) //token "记住我"功能的token过期时间(秒) .tokenValiditySeconds(3600); }
@Bean public PersistentTokenRepository persistentTokenRepository() { JdbcTokenRepositoryImpl jdbcTokenRepository = new JdbcTokenRepositoryImpl();
//第一次启动的时候需要手动创建Remember-Me的数据库表
//jdbcTokenRepository.setCreateTableOnStartup(true);
jdbcTokenRepository.setDataSource(dataSource);
return jdbcTokenRepository;
}
标签:inpu name figure type tps pos prot security ted
原文地址:https://www.cnblogs.com/cearnach/p/9090388.html