복붙노트

[SPRING] Thymeleaf의 산술 연산

SPRING

Thymeleaf의 산술 연산

어떻게 thymeleaf에서 산술 연산을 할 수 있습니까? 나는 여러 가지 방법으로 시험을했다. 그러나 출력을 얻을 수 없습니다. U가 알고 있으면 알려주세요.

여기 내 코드가 있습니다 :

/*Dummy Content */ 
<p class="quan-inc-dec">
    <input type="hidden" name="productId" th:value="*{product.id}" class="productId"/>
    <input type="hidden" name="orderItemId" th:value="*{id}" class="orderItemId"/>
    <input type="button" name="minus" class="minus" value="-" autocomplete="off"/>
    <input type="text" name="quantity" value="1" class="result" autocomplete="off" th:value="*{quantity}"/>
    <input type="button" name="plus" class="plus" autocomplete="off" value="+"/>
</p>
/*Dummy Content End*/
<span th:text="${${obj.baseRetailPrice}*${obj.aa}}"><!-- I need the Result Here --></span>

해결법

  1. ==============================

    1.이렇게 :

    이렇게 :

    <div th:with="result=${obj.baseRetailPrice * obj.aa}">
      <span th:text="${result}"></span>
    </div>
    
  2. from https://stackoverflow.com/questions/21775217/arithmetic-operation-in-thymeleaf by cc-by-sa and MIT license