我已经创建了 Spring Boot 2 WebFlux 应用程序(基于 Spring Cloud Gateway 项目),现在尝试配置自定义登录页面而不是标准:
@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) {
return http.httpBasic().and()
.authorizeExchange()
.anyExchange().authenticated()
.and()
.formLogin().loginPage("/login")
.and()
.csrf().disable()
.build();
}
我尝试使用 Thymeleaf 通过登录 html 页面创建和控制器设置来呈现此页面:
@Controller
public class LoginController {
@RequestMapping(value = "/login")
public Mono<String> getLoginPage() {
return Mono.just("/templates/login.html");
}
}
但它不起作用。任何人都可以解释如何做到这一点,我应该使用 Thymeleaf 吗?也许这已经实现并且在 GitHub 上?