Jsp page, change the amount from 1000 to 10.00

problem description

the fields stored in the amount are stored in quantiles. When displayed, separate the last two places with a decimal point 1000 > 10.00

the environmental background of the problems and what methods you have tried

  1. < fmt:formatNumber > can operate on decimal points. Do I need to write to the custom pattern attribute if the whole number is converted to a decimal point?
  2. use ${fn:substring (str, start, end} to intercept separately, and the decimal point is displayed in the middle.
    2.1 when intercepting, because the length of the amount is not fixed, I need to get the length of the amount first, so the ${fn:length (${orderRooms.price})} method is wrong. What is the reason for writing another ${}?
    2.2 curve first set an object, and ${fn:length (price)} reported an error: Problems calling function "fn:length"
  3. can I write a js myself and then call it inline, < I > formatXXX (${orderRooms.price}) < / I > ?

related codes

<c:set var="price"  scope="page" value="${orderRooms.price}"/>

${price}

<c:set var="priceLength" value="${fn:length(price)}" /> <c:set var="pricePrefix" value="${fn:substring(orderRooms.price, 0, priceLength-2)}" /> <c:set var="priceSuffix" value="${fn:substring(orderRooms.price, priceLength-2, priceLength)}" />

${priceLength}--${pricePrefix}--${priceSuffix}

:<i>${orderRooms.price}</i>

what result do you expect? What is the error message actually seen?

the questions of the above three methods hope to be answered;
the end result is that 1000 > 10.00 can also be solved by other methods;

Apr.09,2021

  

/ 100is fine. Although you can't keep the following zeros, it's okay to convert into elements. [hematemesis]

Menu