実現したいこと
index.htmlからtemplates/01/home.htmlへ遷移したいです。
大変情けないのですがご教示頂けますでしょうか。
発生している問題・分からないこと
Springが指定されたパスに対応する静的ファイルを見つけられなかった旨のエラーメッセージが表示されています。
This application has no configured error view, so you are seeing this as a fallback. Sat Mar 09 04:50:44 JST 2024 [51a5dce7-6] There was an unexpected error (type=Not Found, status=404). No static resource 01/home.html. org.springframework.web.reactive.resource.NoResourceFoundException: 404 NOT_FOUND "No static resource 01/home.html." at org.springframework.web.reactive.resource.ResourceWebHandler.lambda$handle$1(ResourceWebHandler.java:431) Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: Error has been observed at the following site(s): *__checkpoint ⇢ HTTP GET "/01/home.html" [ExceptionHandlingWebHandler]
該当のソースコード
application.properties
1spring.thymeleaf.prefix=classpath:/templates/
com/***/sample/DemoController.java
1package com.example.sample.controller; 2 3import org.springframework.stereotype.Controller; 4import org.springframework.web.bind.annotation.RequestMapping; 5 6@Controller 7public class DemoController { 8 9 @RequestMapping("/") 10 public String sample() { 11 return "index"; // index.html を表示 12 } 13 14 @RequestMapping("/01") 15 public String home() { 16 return "home"; // 01/home.html を表示 17 } 18}
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="utf-8"> <title>トップ画面</title> </head> <body> <h1>Hello World!!</h1> <!-- リンク先のパス --> <a th:href="@{/01/home.html}">home.html</a> </body> </html>
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
html
1<body> 2 <h1>Hello World!!</h1> 3 <!-- リンク先のパス --> 4 <a th:href="@{/01/home.html}">home.html</a> 5</body>
上記のリンク先のパスを指定する部分が間違えていると思うのですが、何故がリンクできません。
対話型最終的に対話型AIも用いてみたのですが、解消できませんでした。
補足
特になし
回答1件
あなたの回答
tips
プレビュー