[개발] Thymeleaf and Controller 구성
                
                    필기자                
                                                
            
            
                                2022-10-14 16:27
                                11,058
                0
                                            
        본문
templates/thymeleafEx/thymeleafEx01.html 파일 생성 및 내용 작성
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <p th:text="${data}">Hello Thymeleaf!!</p>
    </body>
</html>
kr/ac/gachon/shop/controller/ThymeleafExController.java 파일 생성 및 내용 작성
@Controller
@RequestMapping(value="/thymeleaf")
public class ThymeleafExController {
    @GetMapping(value = "/ex01")
    public String thymeleafExample01(Model model) {
        //http://localhost:8080/thymeleaf/ex01
        model.addAttribute("data", "타임리프 예제 입니다.");
        return "thymeleafEx/thymeleafEx01";
    }
}
결과 http://localhost:8080/thymeleaf/ex01

                                                
                                        
                                
댓글목록0