Spring boot cannot find index.html under webapp folder

后端 未结 2 1393
清歌不尽
清歌不尽 2020-12-06 01:58

I read the following documentation from spring.io and it said By default Spring Boot will serve static content from a directory called /static (or /public or /resource

2条回答
  •  醉话见心
    2020-12-06 02:33

    @RestController
    public class IndexController {
    
        @RequestMapping("/")
        public String index(){
            System.out.println("Looking in the index controller.........");
            return "index";
        }
    
    }
    

    Problem is here, you are using @RestController, so in this case, if you write "return 'index';" spring boot covers it as just string answer. You need use @Controller annotation instead.

提交回复
热议问题