๐ŸŽจ Cocostudio + Thymeleaf ํ†ตํ•ฉ ๊ฐ€์ด๋“œ

๐Ÿ“‹ ์‹œ๋‚˜๋ฆฌ์˜ค: Cocostudio HTML์„ Thymeleaf๋กœ ๋ณ€ํ™˜

Cocostudio์—์„œ ์ƒ์„ฑํ•œ HTML์— ๋™์  ๊ฐ’์„ ์„œ๋ฒ„์—์„œ ์ฃผ์ž…ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

1๏ธโƒฃ Cocostudio ์›๋ณธ HTML

<!-- Cocostudio์—์„œ ์ƒ์„ฑํ•œ HTML --> <div class="user-info"> ์‚ฌ์šฉ์ž: {username} ์ด๋ฉ”์ผ: {email} </div> <script> const config = { apiEndpoint: '{api-endpoint}', secretKey: '{encrypted-secretKey}', userId: '{user-id}' }; </script>

2๏ธโƒฃ Thymeleaf๋กœ ๋ณ€ํ™˜ (์„œ๋ฒ„์—์„œ ๋™์  ์ฃผ์ž…)

<!-- Thymeleaf ๋ฌธ๋ฒ• ์ถ”๊ฐ€ --> <html xmlns:th="http://www.thymeleaf.org"> <div class="user-info"> ์‚ฌ์šฉ์ž: <span th:text="${username}">ํ™๊ธธ๋™</span> ์ด๋ฉ”์ผ: <span th:text="${email}">test@example.com</span> </div> <script th:inline="javascript"> /*<![CDATA[*/ const config = { apiEndpoint: /*http://localhost:8080/api*/ 'http://localhost:8080/api', secretKey: /*AES256_ENCRYPTED_KEY_SAMPLE_12345*/ 'default-key', userId: /*USER_67890*/ '12345' }; /*]]>*/ </script>

3๏ธโƒฃ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ

@Controller public class CocostudioController { @GetMapping("/cocostudio-page") public String cocostudioPage(Model model) { // ์„œ๋ฒ„์—์„œ ๋™์  ๊ฐ’ ์ฃผ์ž… model.addAttribute("username", "๊น€์ฒ ์ˆ˜"); model.addAttribute("email", "kim@example.com"); model.addAttribute("apiEndpoint", "https://api.production.com/api"); model.addAttribute("encryptedSecretKey", "AES256_ENCRYPTED_KEY"); model.addAttribute("userId", "USER_67890"); return "cocostudio-page"; // templates/cocostudio-page.html } }

4๏ธโƒฃ ์‹ค์ œ ๋ Œ๋”๋ง ๊ฒฐ๊ณผ (ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ฐ›๋Š” HTML)

JavaScript Config (๋™์  ์ฃผ์ž…):
apiEndpoint: http://localhost:8080/api
secretKey: AES256_ENCRYPTED_KEY_SAMPLE_12345
userId: USER_67890

โœ… Thymeleaf์˜ ์žฅ์ 