๐ŸŒธ [SPRING BOOT] | ํƒ€์ž„๋ฆฌํ”„ -TemplateInputException (layout, contorller)

0
post-thumbnail

๐ŸŸฆ basiclayout๊ณผ thymeleaf์— ๋ฏธ์น˜๋Š” ์˜ํ–ฅ

๐Ÿ”น ์—๋Ÿฌ๋ฉ”์‹œ์ง€

โœ… TemplateInputException

org.thymeleaf.exceptions.TemplateInputException: 
An error happened during template parsing 
(template: "class path resource [templates/user/join.html]")

๐Ÿ”น ์›์ธ

  • basiclayout์ด ์—†๋Š”๋ฐ ์ถ”๊ฐ€๋ฅผ ํ•ด์„œ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋Š” ๊ฒƒ์ด๋‹ค

์Šคํฌ๋ฆฐ์ƒท(25)

๐Ÿ”น ํ•ด๊ฒฐ

basiclayout ์ง€์šฐ๋‹ˆ๊นŒ ์—๋Ÿฌ๊ฐ€ ์—†์–ด์กŒ๋‹ค

๐Ÿ”น ๋ฐฐ์šด ๊ฒƒ

  • TemplateInputException์€ html๋ฌธ์ œ์ด๋‹ค
  • html์•ˆ์—์„œ thymeleafํƒœ๊ทธ๋“ค์—์„œ ๋ฌธ์ œ๊ฐ€ ์ผ์–ด๋‚œ ๊ฒƒ์ด๋‹ค

๐ŸŸฆ Controller ๋ฉ”์†Œ๋“œ์˜ ์ธ์ž๊ฐ€ thymeleaf์— ๋ฏธ์น˜๋Š” ์˜ํ–ฅ

โœ… th:object="${}"

โœ… th:field="*{}"

  • getMapping์€ ํšŒ์›๊ฐ€์ž…์ฐฝ๋งŒ ์—ด์–ด์ฃผ๋ฉด ๋˜๋Š”๋ฐ ์™œ UserEntity ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ ๊ฑธ๊นŒ?
@GetMapping("/join")
public void join(UserEntity userEntity) {}
  • th:object="${}"
  • th:field="*{}"
    ๋ฅผ ์“ฐ๊ธฐ ์œ„ํ•ด์„œ UserEntity ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ์ด๋‹ค
  • ์•ˆ์“ฐ๋ฉด ์—๋Ÿฌ๊ฐ€ ํ„ฐ์ง„๋‹ค

โœ… ์—๋Ÿฌ ๋ฉ”์‹œ์ง€

There was an unexpected error 
(type=Internal Server Error, status=500).
An error happened during template parsing 
(template: "class path resource [templates/user/login.html]")
org.thymeleaf.exceptions.TemplateInputException: 
An error happened during template parsing 
(template: "class path resource [templates/user/login.html]")
profile
๋ช‡ ๋ฒˆ์„ ๋„˜์–ด์ ธ๋„ ์•ž์œผ๋กœ ๊ณ„์† ๋‚˜์•„๊ฐ€์ž

0๊ฐœ์˜ ๋Œ“๊ธ€