java - BigDecimal in JSTL, divide by int or double returns integer -


<fmt:formatnumber var="instamount" value="${invoice.amount / offer.gettotalinstallments()}" minfractiondigits="2" /> 

where amount bigdecimal in java , totalinstallments int. tried setting totalinstallments double nothing changes. returns integer, behaves when divide 2 integers in java, integer.

am missing or there workaround?

the easiest solution calculation in controller/servlet , use result on view page. think calculations should done in controller , not view. use divide() method on bigdecimal.

that said, if want in view have define jstl function in tag library , create static version of divide accepts bigdecimal , int diving by.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -