Spring boot MVC + DB

미니멀리즘·2023년 1월 10일
0

최신버전은 클라이드 기반이라 로컬저장소 지원이 미흡함

Deploy(배포)는 보통 war파일로 함

com.code.bootexample.thymeleafexample.controller
DemoController.java

package com.code.bootexample.thymeleafexample.controller;

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

@Controller
public class DemoController {

	@GetMapping("/hello")
	public String sayHello(Model theModel) {
		
		theModel.addAttribute("theDate", new java.util.Date());
		
		return "helloworld";
	}
}

src/main/resources/templates
helloworld.html

<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
   <title>Thymeleaf Example</title>
   
</head>

<body>
   
   Time on Server(p) : <p th:text="${theDate}"></p>  
   <p th:text = "'Time on Server:::' + 	${theDate}"/>
   Time on Server(span) : <span th:text="${theDate}"></span>

</body>
</html>

src/main/resources
application.properties

server.port = 1114

CSS

src/main/resources
static/css 폴더
css파일 작성

.funny{
	font-style: italic;
	color: green;
}

link 추가

<link rel="stylesheet" th:href = "@{/css/demo.css}"/>
profile
웹 개발자

0개의 댓글

관련 채용 정보