Java

[Spring Boot] /index.html 파일 static 폴더가 아닌 templates 폴더에서 호출되게 하는 방법

솔솔 2021. 6. 24. 15:43
반응형

Spring Boot 프로젝트를 실행하게 되면 /static/index.html이 호출됩니다.

근데 저는 애초부터 templates 폴더에서 호출되게 하고싶어서 어떤 방법이 있을까하다...

@Controller
public class MainController {

	@GetMapping(value = "/")
    public String loadPage() throws Exception {
        return "/index.html";
    }
}

MainController에 / 로 접근하는 모든 것을 index.html로 보냈습니다. 그러면 templates 폴더 하위에 있는 index.html이 호출돼요! 

반응형