SpringBoot으로 웹 출시까지 #2

springboot logo

2. thymeleaf를 이용한 화면 작성

1 mythymeleaf 만들기

https://spring.io/guides/gs/serving-web-content/

https://start.spring.io/

 

project : maven

springboot :  최대한 낮은 버전 / SNAPSHOT X로 선택

artifact, name : mythymeleaf

java: 8

dependencies : Thymeleaf / Spring Web / Spring Boot DevTools

2 greeting.html 만들기

greeting.html 만들기

3 GreetingController 만들기

controller 폴더를 만들어서 GreetingController 클래스 만들기

 

package com.example.mythymeleaf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class GreetingController {

@GetMapping("/greeting")
public String greeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
model.addAttribute("name", name);
return "greeting";
}

}

4 visual Studio code 열어서 html 편집

<!DOCTYPE HTML>
<html xmlns:th=“http://www.thymeleaf.org”>
<head>
    <title>Getting Started: Serving Web Content</title>
    <meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8” />
</head>
<body>
    <p th:text=“‘Hello, ‘ + ${name} + ‘!'”>홍길동</p>
</body>
</html>

5 Live Server 다운로드 및 실행 / Five Server X

6 인텔리제이 mythymeleaf 실행

초록 삼각형 눌러서 실행 시키기

“Web server failed to start. Port 8080 was already in use.” 가 발생하셨다면 인텔리제이를 모두 껐다가 다시 실행시키시면 바로 해결됩니다.

“SpringBoot으로 웹 출시까지 #2”의 264개의 댓글

  1. I was skeptical at first but the verification process was actually quite quick and straightforward. The game selection is massive and I never have to wait for a title to load. It really feels like a safe haven for anyone who values reliability over flashy graphics. Cheers to the team for keeping it simple br5gbet86

  2. Love how InPlay prioritizes wellbeing over quick wins! It’s refreshing to see a platform that encourages breaks and responsible habits right from the start. Check out inplay legit for a safer, more enjoyable gaming experience today.

  3. 핑백: obtaining tadalafil online

댓글 달기

이메일 주소는 공개되지 않습니다.