implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//lombok 관련
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok:1.18.22' // 테스트 의존성 추가
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' // 테스트 의존성 추가
src/main/resources/templates/...html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<!-- 한글 utf-8 설정 -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
<h1>!!!Hello!!!</h1>
<div th:text="${name}"></div>
</body>
</html>
package com.karim.simpleBoard.controller;
import ch.qos.logback.classic.Logger;
import lombok.RequiredArgsConstructor;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@Controller
@RequiredArgsConstructor
public class TestController {
@GetMapping("/hello")
public String hello(String name, Model model) {
//http://localhost:8080/hello?name=karim
model.addAttribute("name", name);
logger.info("{} => {}", "name", name);
//html 이름
return "hello";
}
}
package com.karim.simpleBoard;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebApplication {
public static void main(String[] args) {
SpringApplication.run(WebApplication.class, args);
}
}