chellapandi k chellapandi k - 9 months ago 87
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.

Answer Source

Perform arithmetic like this:

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

Refer to your variable like this:


Or just:

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