* 해당 시리즈는 인프런 김영한님 강좌인 스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술 내용
강의를 학습하며 개인적으로 정리한 글이며, 저작권 문제나 잘못된 부분이 있다면 지적해주시면 감사하겠습니다.
resources/static/indec.html
<!DOCTYPE HTML>
<html>
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
Hello
<a href="/hello">hello</a>
</body>
</html>
static/index.html
을 올려두면 Welcome page기능을 제공한다.[인텔리J]
java>hello.hellospring 하단 controller 폴더 생성 후 class 파일 생성해서 어노테이션 @controller 작성.
thymeleaf 템플릿엔진 동작 확인
동작 환경 그림
viewResolver
)가 화면을 찾아서 처리한다. resources:templates/
+{ViewName}+.html
참고:
spring-boot-devtools
라이브러리를 추가하면,html
파일을 컴파일만 해주면 서버 재시작 없이 View 파일 변경이 가능하다.
인텔리J 컴파일 방법: 메뉴 build -> Recompile
콘솔로 이동
1../gradlew build
2. cd build/libs
3. java -jar hello-spring-0.0.1-SNAPSHOT.jar
4. 실행 확인
* 인텔리 J와 동시에 열 수 없으므로 둘 중 하나만 열어야 한다.