Spring boot error: Check your ViewResolver setup, springviewresolver
Whitelabel Error Page
This application has no explicit mapping for/error, so you are seeing this as a fallback.
Fri Mar 23 10:34:26 CST 2018
There was an unexpected error (type = Internal Server Error, status = 500 ).
Circular view path [index]: wocould dispatch back to the current handler URL [/home/index] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation .)
Solution:
Method 1Add Annotations to the request method:@ ResponseBody, No template file required
@RequestMapping("/home")@Controller()public class HomeController { @ResponseBody @RequestMapping("/index") public String index() { return "index"; }}
Method 2. Use thymeleaf Template
Add a static template dependency to the dependencies element of pom. xml.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
Create an html template file in resources/templates/. The file name is the same as the string of the Request Method return. The extension is html: index.html.
<!DOCTYPE html>
@RequestMapping("/home")@Controller()public class HomeController { @RequestMapping("/index") public String index(HashMap<String,Object> map) { map.put("data","index.html"); return "index"; }}