[Spring Boot][문제해결] STS에서 Mustache 사용 설정 및 한글 깨짐 문제 해결
"이동욱. (2019). 스프링 부트와 AWS로 혼자 구현하는 웹 서비스. 프리텍"으로 실습 중인데 책에서는 IntelliJ를 IDE로 사용하고 있지만 나의 경우 STS로 실습을 진행 중이다. "Chapter 04 - 머스태치로 화면 구성하기"에 대한 실습을 하던 중 STS에서는 Mustache 설정에 차이가 있음을 확인했다.
▍build.gradle
STS에서 Gradle의 dependencies에 아래 코드를 추가하고 Refrash 한다.
implementation 'org.springframework.boot:spring-boot-starter-mustache'
▍src/main/resources/templates/index.mustache
index.mustache 파일을 생성하고 아래 코드를 작성한다.
<!DOCTYPE HTML>
<html>
<head>
<title>스프링 부트 웹서비스</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
</head>
<body>
<h1>스프링 부트로 시작하는 웹 서비스</h1>
</body>
</html>
▍src/main/java/com/tistory/postforty/book/springboot/web/IndexController.java
IndexController.java 파일을 생성하고 아래 코드를 작성한다.
package com.tistory.postforty.book.springboot.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class IndexController {
@GetMapping("/")
public String index() {
return "index";
}
}
서버를 재 시작하고 매핑한 "/" 경로로 진입하면 [그림 1]과 같은 화면이 나타난다. 하지만 한글이 깨져 있다.
▍build.gradle
id 'org.springframework.boot' version '2.6.8'
Spring Boot 버전이 '2.7.3'인 경우-이 글을 작성하고 있는 시점에서는-한글이 깨진다고 한다. 따라서 Gradle의 plugins 설정에서 Spring Boot 버전을 '2.6.8'로 변경 후 Refresh 한다. 그러면 [그림 2]와 같이 한글이 정상적으로 표현되는 것을 확인할 수 있다.
Spring Boot | STS4에서 mustache 사용하기
인텔리제이 대신 STS4를 사용하면서 <스프링 부트와 AWS로 혼자 구현하는 웹 서비스> 책을 보고 있는데 IDE가 다르다보니 불편한 점이 많다. STS4에서 mustache 사용하는 법을 정리해본다.build.gradle에서
velog.io
▍추가 : 엉뚱한 html syntax hightlignt 해결
mustache 파일의 html syntax hightlignt가 엉뚱하다. 이 문제를 해결하고자 한다.
✎ 참고: https://goodteacher.tistory.com/469?category=762301
[eclipse] eclipse에서 mustache 개발
열심히 vscode에서 spring boot와 mustache로 개발을 하다가 느닷없이 vscode가 자주 뻗는 증상이 왔다. 그래서 부랴 부랴 eclipse에서 개발을 이어가려고 하는데... 아뿔싸. eclipse에서는 mustahe를 지원하는 p.
goodteacher.tistory.com