
controller 가 먼저 hello-static을 찾아봄 (controller가 우선 순위!)
package hello.hellospring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HelloController {
@GetMapping("hello")
public String hello(Model model) {
model.addAttribute("data", "spring!!");
return "hello"; // 'resources/templates/hello.html' 을 스프링이 찾아서 Thymeleaf 템플릿 엔진이 렌더링 해 줌
// 컨트롤러에서 리턴 값으로 문자를 반환하면 뷰 리졸버(`viewResolver`)가 화면을 찾아서 처리한다.
// 스프링 부트 템플릿 엔진 기본 viewName 매핑
// `resources(폴더):templates/` + {ViewName} + `.html`
}
}
위와 같이 hello 컨트롤러는 생성해서 매핑해놨는데 hello-static 컨트롤러는 없음
—> 스프링부트가 resources/static/hello-static.html 이렇게 경로를 찾아감