| |

VerySource

 Forgot password?
 Register
Search
View: 858|Reply: 1

jstl display decimal problems, ask. . .

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-12 14:30:01
| Show all posts |Read mode
Hello everyone, I use a SQL statement to query a result, and the result is 0.3 on the mysql query browser, but I use jstl <c: out value = ""> to display it is a very long decimal: 0.30000000000000004,

May I ask what is the reason? How to solve?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-28 09:45:01
| Show all posts
You didn't use formatting
The introduction of the java.util.Currency class, the currencyCode attribute priority of <fmt:formatNumber> **** exceeds
            currencySymbol property. But for older versions of JDK, the currencySymbol attribute has priority.
            maxIntegerDigits, minIntegerDigits, maxFractionDigits and
            The minFractionDigits attribute is used to control the number of significant digits displayed before and after the decimal point. These attributes require integer values.
            groupingUsed
            The attribute has a boolean value and controls whether to group the numbers before the decimal point. For example, in the English language environment, divide every three digits of the larger number into a group, and each group is delimited by a comma. Other locales use periods or spaces to delimit such groups. The default value of this attribute is
            true.
            Listing 3 shows a simple currency example, which itself is an extension of Listing 1. In this case, don’t specify currencyCode or
            currencySymbol property. The currency is determined by the locale setting.

            Listing 3. Use the <fmt:formatNumber> tag to display currency values

<table>
<fmt:timeZone value="US/Eastern">
<c:forEach items="${entryList}" var="blogEntry"
varStatus="status">
<c:if test="${status.first}">
        <tr><td align="left" class="blogDate">
          <fmt:formatDate value=
              "${blogEntry.created}" dateStyle="full"/>
        </td></tr>
      </c:if>
      <tr><td align="left" class="blogTitle">
        <c:out value="${blogEntry.title}" escapeXml="false"/>
      </td></tr>
    <tr><td align="left" class="blogText">
      <c:out value="${blogEntry.text}" escapeXml="false"/>
      <font class="blogPosted">
        [My <fmt:formatNumber value="0.02" type="currency"/>
         posted at <fmt:formatDate value="${blogEntry.created}"
                                   pattern="h:mm a zz"/>]
      </font>
    </td></tr>
  </c:forEach>
  </fmt:timeZone>
</table>
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list