2

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Trts
  • 985
  • 1
  • 11
  • 24

2 Answers2

1

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

Daniel Taub
  • 5,133
  • 7
  • 42
  • 72
0

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.
  }
}
Qiu Zhou
  • 1,235
  • 8
  • 12