thymeleaf - basic objects
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
package com.example.thymeleaf.basic;
|
package com.example.thymeleaf.basic;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -49,6 +51,19 @@ public class BasicController {
|
|||||||
return "basic/variable";
|
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
|
@Data
|
||||||
static class User {
|
static class User {
|
||||||
private String username;
|
private String username;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>식 기본 객체 (Expression Basic Objects)</h1>
|
||||||
|
<ul>
|
||||||
|
<li>request = <span th:text="${#request}"></span></li>
|
||||||
|
<li>response = <span th:text="${#response}"></span></li>
|
||||||
|
<li>session = <span th:text="${#session}"></span></li>
|
||||||
|
<li>servletContext = <span th:text="${#servletContext}"></span></li>
|
||||||
|
<li>locale = <span th:text="${#locale}"></span></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<h1>편의 객체</h1>
|
||||||
|
<ul>
|
||||||
|
<li>Request Parameter = <span th:text="${param.paramData}"></span></li>
|
||||||
|
<li>session = <span th:text="${session.sessionData}"></span></li>
|
||||||
|
<li>spring bean = <span th:text="${@helloBean.hello('Spring!')}"></span></li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user