From b8c001f69f5555cc97599850197cd19841bf9fbb Mon Sep 17 00:00:00 2001 From: haerong22 Date: Sat, 3 Jul 2021 22:05:43 +0900 Subject: [PATCH] thymeleaf - basic objects --- .../thymeleaf/basic/BasicController.java | 15 ++++++++++++ .../templates/basic/basic-objects.html | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 thymeleaf/src/main/resources/templates/basic/basic-objects.html diff --git a/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java b/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java index eafb3ac6..6c40e4cb 100644 --- a/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java +++ b/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java @@ -1,11 +1,13 @@ package com.example.thymeleaf.basic; import lombok.Data; +import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import javax.servlet.http.HttpSession; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -49,6 +51,19 @@ public class BasicController { return "basic/variable"; } + @GetMapping("/basic-objects") + public String basicObject(HttpSession session) { + session.setAttribute("sessionData", "Hello Session"); + return "basic/basic-objects"; + } + + @Component("helloBean") + static class HelloBean { + public String hello(String data) { + return "Hello" + data; + } + } + @Data static class User { private String username; diff --git a/thymeleaf/src/main/resources/templates/basic/basic-objects.html b/thymeleaf/src/main/resources/templates/basic/basic-objects.html new file mode 100644 index 00000000..e71d33f7 --- /dev/null +++ b/thymeleaf/src/main/resources/templates/basic/basic-objects.html @@ -0,0 +1,24 @@ + + + + + Title + + +

식 기본 객체 (Expression Basic Objects)

+ +

편의 객체

+ + + \ No newline at end of file