状況
- SpringBoot
- /greetingにアクセスして、greeting.htmlを表示したい
@Controller class MyController { @RequestMapping("greeting") fun greeting():String{ return "greeting" } }
問題
/greetingにアクセスしたときに以下のようなエラーが発生する
jakarta.servlet.ServletException: Circular view path [greeting]: would dispatch back to the current handler URL [/greeting] again. Check your ViewResolver setup!
原因
thymeleaf等のテンプレートエンジンが連携できていない
このような状況の場合、SpringBootは指定された文字列にRoutingするだけなので、/greetingの呼び出しをループするだけになります
Intellijを使用している場合、そもそもマッピングできていない旨を表示してくれます。

thymeleaf等のテンプレートエンジンを追加する
gradleを使用する場合は以下のようにします。
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
Intellij上でも認識されます
