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”의 231개의 댓글

  1. 핑백: vardenafil vs sildenafil full comparison

  2. Giving props to jl9casino for their great selection of games. Something for everyone, really. I especially enjoy the insert game type, if known, otherwise just leave as ‘specific games’. Great experience all around. jl9casino

  3. Alright mates, just had a cracking session on 188betzokb! Site’s easy to navigate, even after a few cheeky pints. Great odds too, nabbed myself a decent win. Definitely worth a look-in. Check it out here: 188betzokb

  4. Found this gem while scrolling through some forums and decided to give it a shot. The interface is clean and I love how easy it is to filter live dealer games. Withdrawals usually reach my account within a day which I really appreciate. A solid option for anyone who wants a stress free gaming environment. vnshber

  5. The sports coverage here is absolutely top notch with competitive odds on all major leagues. I also enjoy the casino lobby which has a great mix of classic and modern titles. A complete gaming experience that keeps me coming back. nhacaiuytin88

댓글 달기

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