简体   繁体   中英

How to show percentage ratio in JSP using JSTL or jQuery?

I am using JSTL in my jsp page to iterate my object and then show in the table as shown below and it works fine -

<c:forEach items="${test.dataList}" var="m3">
    <tr>
        <th>${m3.hostName}</th>
        <td>${m3.totalCall}</td>
        <td>${m3.timeoutCount}</td>
    </tr>
</c:forEach>

Now what I am looking to do is, I want to add percentage of timeoutCount as compare to totalCall next to ${m3.timeoutCount} using JSTL. Below is an example -

MachineA
10000
25 (0.25%)

But if totalCall is 0 then I don't want to show percentage ratio at all. Is this possible to do in JSP page using JSTL or jquery?

try this one:

<c:forEach items="${test.dataList}" var="m3">
    <tr>
        <th>${m3.hostName}</th>
        <td>${m3.totalCall}</td>
        <td>${m3.timeoutCount}
<c:if test="${m3.totalCall > 0}">
   <c:out value="%"/>
</c:if>
</td>
    </tr>
</c:forEach>

I haven't tested it but that should do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM