Skip to content

Instantly share code, notes, and snippets.

@namkyu
Last active August 17, 2018 07:22
Show Gist options
  • Save namkyu/255ff886df99f0b7ecadbd8ca9b9aa43 to your computer and use it in GitHub Desktop.
Save namkyu/255ff886df99f0b7ecadbd8ca9b9aa43 to your computer and use it in GitHub Desktop.
basic #thymeleaf

페이지 레이아웃

<div class="col-md-3 left_col" th:replace="fragments/left :: left">
    left 메뉴
</div>

fragments 디렉토리에 left.html 파일 생성 후 다음의 코드 추가
<div class="col-md-3 left_col" th:fragment="left">...</div>

for문

<tr class="even pointer" th:each="product : ${productList}">

<td th:text="${product.productId}">11</td>

<a th:href="@{'/product/detail?productId=' + ${product.productId}(action='view')}" th:text="${product.productName}">테스트 상품</a>

<td th:text="${product.associateCompanies?.associateCompanyName}">11111111</td>

<td th:text="${product.saleStatus.statusName}">

표현식

<td th:text="${#numbers.formatInteger(product.salePrice, 1, 'DEFAULT')}">1,000</td>

<td th:text="${#temporals.format(product.changed, 'yyyy-MM-dd HH:mm:dd')}">2010-01-01</td>

<input type="number" name="saleableQuantityPerCompany" th:value="${product != null} ? ${product?.saleableQuantityPerCompany}">

<input type="number" name="salePrice" th:with="salePrice=${product != null} ? ${product?.salePrice}" th:value="${product != null} ? ${#numbers.formatDecimal(salePrice, 0, 0)}" value="10000">

<form id="productForm" name="productForm" th:action="@{/product/form}" method="post">

<input type="hidden" id="action" name="action" th:value="${#httpServletRequest.getParameter('action')}">

<script th:src="@{/js/jquery.min.js}"></script>

<div class="x_content">
	[[${messages}]]
</div>

<a th:if="${#arrays.contains(@environment.getActiveProfiles(), 'op')}" th:onclick="'removeRefund(\'' + ${refund.orderId} + '\')'">Delete</a>

[HTML 코드 출력]
th:utext="${messages}"

selectbox

<select name="associateCompanyId">
    <option th:each="company : ${associateCompanies}"
            th:value="${company.associateCompanyId}"
            th:text="${company.associateCompanyName}"
            th:selected="${company.associateCompanyId == product?.associateCompanies?.associateCompanyId}">Wireframe</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment