Circular view path in Spring

Viewed 86

How can I cope with a circular view path error?

package com.example.PrinterManager;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class ControllerPrinter {
    @GetMapping("/home")
    public String getHomePage() {
       return "home"; // Breakpoint.
    }
}

The interpreter stops at the breakpoint. But then the error occurs.

As for the template, it is here (visible in the picture)

PrinterManager\src\main\resources\templates\home.html

enter image description here

2 Answers

Simply change @Controller@RestController,
For more details look at that

There are two possible ways to solve this problem:

1: add a thymeleaf to your dependencies:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

if no luck, try next one:

2: change your home.html to another name, for example, index.html, then change your controller to:

@Controller
public class ControllerPrinter {
  @GetMapping("/home")
  public String getHomePage() {
     return "index"; // Breakpoint.
  }
}
Related