將@RestController改成@Controller引入了thymeleaf依賴,前臺請求后臺還是報錯。
2018-08-25 11:53:47.848 ?INFO 15024 --- [nio-8080-exec-1] o.a.c.c.C.[.[localhost].[/spring-boot] ? : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-08-25 11:53:47.848 ?INFO 15024 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet ? ? ? ?: FrameworkServlet 'dispatcherServlet': initialization started
2018-08-25 11:53:47.879 ?INFO 15024 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet ? ? ? ?: FrameworkServlet 'dispatcherServlet': initialization completed in 31 ms
2018-08-25 11:53:48.051 ERROR 15024 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine ? ? ? ? ? ? : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "index": Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
2018-08-25 11:53:48.051 ERROR 15024 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] ? ? ?: Servlet.service() for servlet [dispatcherServlet] in context with path [/spring-boot] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE]
創建好了template/index.html文件。
2018-08-25
你看一下pom.xml里面是不是少了thymeleaf的依賴