Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have created Spring Boot 2 WebFlux application (based on Spring Cloud Gateway project) and now try to configure custom login page instead of standard:

@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) {
    return http.httpBasic().and()
            .authorizeExchange()
            .anyExchange().authenticated()
            .and()
            .formLogin().loginPage("/login")
            .and()
            .csrf().disable()
            .build();

I tried to use Thymeleaf to render this page by means of login html page creation and controller setup:

@Controller
public class LoginController {
    @RequestMapping(value = "/login")
    public Mono<String> getLoginPage() {
        return Mono.just("/templates/login.html");

But it don't working. Can anybody explain how to do this and should I using Thymeleaf at all? Maybe this have already implemented and is on GitHub?

public String getLoginPage() { // assuming that Thymeleaf is present // and a valid src/main/resources/templates/login.html template return "login"; Thank you for response. That helped for problem solving. But now I don't understand why view not resolved. Application context by some reason doesn't contains Thymeleaf view resolver. – Roman Q Mar 2, 2018 at 8:58 More precisely Thymeleaf beans contained in application context, but by some reason view not resolved. – Roman Q Mar 2, 2018 at 9:05

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.