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. [6572]qqee login করুন | বিকাশ দিয়ে অনলাইন স্লট গেম খেলুন,qqee app download করে লাইভ ক্যাসিনো বোনাস অফার উপভোগ করুন। বিকাশ দিয়ে ক্যাসিনো ডিপোজিট করে আজই অনলাইন স্লট গেম খেলার নিয়ম জানুন ও শুরু করুন। visit: qqee

  2. 핑백: Metabolism Basics Resource

  3. 핑백: Sildenafil Timing Reference

  4. [1818]Soul777: অনলাইন ক্যাসিনো সাইট – লগইন,অনলাইনে ক্যাসিনো গেম খেলার জন্য বাংলাদেশি খেলোয়াড়দের পছন্দের সাইট Soul777। এখানে সাইন ইন বা রেজিস্টার করুন, অ্যাপ ডাউনলোড করুন এবং প্রমোশন ও ভিআইপি তথ্য দেখে নিন। visit: soul777

댓글 달기

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