0

I'm trying to follow an official guide: https://spring.io/guides/gs/serving-web-content/ I run the application. Then in a browser http://localhost:8080/greeting

Result:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Aug 29 10:32:01 MSK 2020
There was an unexpected error (type=Internal Server Error, status=500).

That is something at the server side. Here I have what there was in the console: https://dpaste.com/AXBQW2EPV

I believe I need to localize the problem. I suspect the problem hides here: Circular view path [greeting]: would dispatch back to the current handler URL [/greeting] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

Am I right? That is the flow reached the controller and occurred in the infinite loop?

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

1 Answers1

0

This answer explains how a Circular view path exception could occur in detail, you might want to read it: https://stackoverflow.com/a/18815059

For the problem you have now, your can try following possbile solutions:

1、make sure you have the thymeleaf dependency imported correctly and downloaded successfully:

maven:

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

gradle:

    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

2、make sure you have added this header <html xmlns:th="http://www.thymeleaf.org"> in your greeting.html template

3、change greeting mapping name to another one, for example:

@GetMapping("/hello")
public String greeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
    model.addAttribute("name", name);
    return "greeting";
}

then visit http://localhost:8080/hello

Qiu Zhou
  • 1,235
  • 8
  • 12