chellapandi k chellapandi k - 3 months ago 32
Java Question

FreeMarker arithmetic operations in list iteration java

I need to do some arithmetic operations in freemarker template. I have a list of objects and i need to apply the arithmetic operation like below...

<#list order.orderDetails as orderDetail>
<#assign orderTotal=${orderDetail.quantity}*${orderDetail.price}>

I need order total value using this calculation but it doesn't work. It shows

error in syntax. assign tag is not accepting this kind of value injection.


Perform arithmetic like this:

<#assign orderTotal=orderDetail.quantity * orderDetail.price>

Refer to your variable like this:


Or just:

<td>${orderDetail.quantity * orderDetail.price}</td>