
url로 바로 호출.
http://localhost:8080/hello.html
리턴값으로 파일경로 입력한다.
@GetMapping("/hello)
public String hello(){
return "hello.html"
}
리턴값으로 redirect:/ 작성 후 직접 접근 경로 입력
@GetMapping("/hello/redirect)
public String reHello(){
return "redirect:/hello.html"
}
html파일 이름만 입력해주면 된다.
@GetMapping("/hello/templates)
public String helloTemp(){
return "hello"
}
@GetMapping("/html/dynamic")
public String htmlDynamic(Model model) {
visitCount++;
model.addAttribute("visits", visitCount);
return "hello-visit";
}
페이지에 값 전달하기
<div>
(방문자 수: <span th:text="${visits}"></span>)
</div>