###前提・実現したいこと
Spring BootとThymeleafでWebアプリを作成
###発生している問題・エラーメッセージ
Spring Bootの公式通りにMainApp内にコントローラーを作るとThymeleafのパスがきちんと通ってindex.htmlが表示されますが、MainAppから切り離してControllerを作るとなぜかThymeleafのパスが通らなくなります。MainApp外のコントローラーから見る場合のThymeleafパスがどこなのかまったくわかりません。どなたかご存知の方教えていただけないでしょうか。
(エラーログ) Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
index.htmlを置いているパス
src/main/resources/templates/index.html
Thymeleafの現在のパス
spring.thymeleaf.prefix=classpath:/templates/
###OKソース (このようにMainApp内でindexに移動することは可能)
Java
1@Controller 2@EnableAutoConfiguration 3public class MainApp { 4 5 @RequestMapping("/") 6 public String index() { 7 return "index"; 8 } 9 10 public static void main(String[] args) throws IOException { 11 SpringApplication.run(MainApp.class, args); 12 } 13 14}
###NGソース (MainApp + コントローラー)
Java
1@ComponentScan 2@EnableAutoConfiguration 3public class MainApp { 4 5 public static void main(String[] args) throws IOException { 6 SpringApplication.run(MainApp.class, args); 7 } 8 9}
@Controller public class IndexController { @RequestMapping("/") public String index() { return "index"; } }
###補足情報(言語/FW/ツール等のバージョンなど)
Java8
Spring-Boot 1.2.1
Jetty
NetBeans
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/10/15 15:14