์กฐ๊ฑด2 [thymeleaf] th:if ์กฐ๊ฑด ์์ ๋ฐฐ์ด์ ๊ธธ์ด ๊ฐ์ ธ์ค๊ธฐ / #arrays.length() thymeleaf์ th:if๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋ฉด ์กฐ๊ฑด์ ํ์ธํ๊ณ true์ผ ๊ฒฝ์ฐ ์์๋ฅผ ํ์ false์ผ ๊ฒฝ์ฐ ์์๋ฅผ ํ์ํ์ง ์๊ฒ ๋๋ค. th:if๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก ์กฐ๊ฑด์ ๊ฒฐ๊ณผ๊ฐ true์ผ ๊ฒฝ์ฐ ํ์๋๊ฒ ๋จ ์กฐ๊ฑด์ ๊ฒฐ๊ณผ๊ฐ false์ผ ๊ฒฝ์ฐ ํด๋น ์์๋ฅผ ํ์ํ๊ณ ์ถ๋ค๋ฉด th:unless๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ค! ๋ฌผ๋ก th:if=${ num != 5 } ๋ก ํด๋ ์๊ด ์๋ค. ํ๋ก์ ํธ ์์ ์ค model๋ก ๋ณด๋ธ ๋ฐฐ์ด ๋ฆฌํฐ๋ด์ด null์ผ ๊ฒฝ์ฐ ์๋ฌ๊ฐ ์๊ธฐ์ง ์๋๋ก th:if๋ฅผ ์ด์ฉํด null์ ๋ํ ์ฒ๋ฆฌ๋ฅผ ํ๋๋ฐ ์๊ฐํ ๋๋ก ์ฒ๋ฆฌ๊ฐ ์ ๋์ง ์์๋ค. ๊ฒ์ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค. java๋ก list๋ฅผ ์ถ๋ ฅํ์ ๋ ํ์คํ ๋น ๊ณต๊ฐ์ธ ๊ฒ์ ํ์ธํ๋ค. list์ ๋ด๊ธด ๊ฐ์ด ์์ด ๋น ๊ณต๊ฐ์ผ ๋ ๊ฒ์ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค๊ฐ ๋์.. 2023. 11. 28. [thymeleaf] layout decorate ์กฐ๊ฑด ๋ถ์ฌ - @{}, @{||} ํ๋ก์ ํธ ์ ์ง๋ณด์๋ฅผ ์ํ ๋ฆฌํฉํ ๋ง ์์ ๋์ค ํ๋์ ํ์ด์ง์์ ์ฌ์ฉ์ ๊ถํ์ ๋ฐ๋ผ thymeleaf์ layout decorate์ ๊ฒฝ๋ก๊ฐ ์กฐ๊ฑด์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋๋ก ์ฒ๋ฆฌํด์ผ ํ๋ค. ์ฒ์์ layout:decorate ์์ฑํ๋ html ํ๊ทธ ๋ถ๋ถ์ th:block์ผ๋ก ๊ฐ์ธ th:if๋ฅผ ์ด์ฉํด ์ฒ๋ฆฌํ๋ ค ํ๋ค. ๊ทธ๋ฌ๋ ์ด๋ ๊ฒ ์ฒ๋ฆฌํ ๊ฒฝ์ฐ 500 ์๋ฌ๊ฐ ๋ฌ๋ค. java.lang.IllegalArgumentException: layout:decorate/data-layout-decorate must appear in the root element of your template ๋ฌธ์ ์ ์ค๋ฅ๋ layout:decorate๋ data-layout-decorate๊ฐ ํ ํ๋ฆฟ์ ์ต์์ ์๋ฆฌ๋จผํธ์ ๋ํ๋์ผ ํ๋ค๋ ๊ฒ์ด๋ค. ๊ฒฐ๊ตญ.. 2023. 11. 26. ์ด์ 1 ๋ค์