0
0

エラー解決:テンプレートが存在しないか、構成されたテンプレートリゾルバのいずれからもアクセスできない可能性があります。

Last updated at Posted at 2024-08-27

エラー:template might not exist or might not be accessible by any of the configured Template Resolvers

和訳:テンプレートが存在しないか、構成されたテンプレートリゾルバのいずれからもアクセスできない可能性があります。

修正前ソース内容

src/main/java/com.example.demo/HelloController.java

package com.example.demo;

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

@Controller
public class HelloController {

	@RequestMapping(value="/hello")
	private String hello(){
	return "hello";
	}
}

src/main/resources/templates/hello.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
hello
</body>
</html>

1,controllerクラスのreturnする文字列を修正(hello.html→hello)

package com.example.demo;

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

@Controller
public class HelloController {

	@RequestMapping(value="/hello")
	private String hello(){
	return "hello";
	}
}

2,springbootを停止して再起動
3,chromeをキャッシュクリーン(shift + f5)

※解決に数時間もかけてしまった...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0