5분 만에 Spring boot와 Thymleaf에서 Hello World
3128 단어 spring-boot
절차



DemoController.javapackage com.example.HelloThymleaf;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class DemoController {
@RequestMapping("/")
public String index(Model model) {
model.addAttribute("msg", "Hello! Thymleaf!!");//Hello! Thymleaf!!はmsgへ格納し、index.htmlへ返します。
return "index";
}
}
index.html<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<title>demo</title>
</head>
<body>
<p th:text="${msg}">ここの文字列は、実行時に ${msg} で置換されます。</p>
</body>
</html>

참조 링크
Reference
이 문제에 관하여(5분 만에 Spring boot와 Thymleaf에서 Hello World), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Hakata2002/items/14db2cd441bdd059658f
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
package com.example.HelloThymleaf;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class DemoController {
@RequestMapping("/")
public String index(Model model) {
model.addAttribute("msg", "Hello! Thymleaf!!");//Hello! Thymleaf!!はmsgへ格納し、index.htmlへ返します。
return "index";
}
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<title>demo</title>
</head>
<body>
<p th:text="${msg}">ここの文字列は、実行時に ${msg} で置換されます。</p>
</body>
</html>
Reference
이 문제에 관하여(5분 만에 Spring boot와 Thymleaf에서 Hello World), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Hakata2002/items/14db2cd441bdd059658f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)