Java 如何使用JSTL或jQuery在JSP中显示百分比比率?
我在我的jsp页面中使用JSTL来迭代我的对象,然后如下图所示显示在表中,它工作得很好-Java 如何使用JSTL或jQuery在JSP中显示百分比比率?,java,jquery,jsp,jstl,Java,Jquery,Jsp,Jstl,我在我的jsp页面中使用JSTL来迭代我的对象,然后如下图所示显示在表中,它工作得很好- <c:forEach items="${test.dataList}" var="m3"> <tr> <th>${m3.hostName}</th> <td>${m3.totalCall}</td> <td>${m3.timeoutCount}</td>
<c:forEach items="${test.dataList}" var="m3">
<tr>
<th>${m3.hostName}</th>
<td>${m3.totalCall}</td>
<td>${m3.timeoutCount}</td>
</tr>
</c:forEach>
但是如果totalCall
为0,那么我根本不想显示百分比比率。在JSP页面中使用JSTL或jquery可以做到这一点吗?试试这个:
<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>
${m3.hostName}
${m3.totalCall}
${m3.timeoutCount}
我还没有测试过,但应该可以。试试这个:
<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>
${m3.hostName}
${m3.totalCall}
${m3.timeoutCount}
我还没有测试过,但应该可以。试试这个:
<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>
${m3.hostName}
${m3.totalCall}
${m3.timeoutCount}
我还没有测试过,但应该可以。试试这个:
<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>
${m3.hostName}
${m3.totalCall}
${m3.timeoutCount}
我还没有测试过,但应该可以。谢谢你的建议。它如何将timeoutCount与totalCall进行划分?您可以进行类似于
${m3.totalCall/m3.timeoutCount}
的划分,谢谢您的建议。它如何将timeoutCount与totalCall进行划分?您可以进行类似于${m3.totalCall/m3.timeoutCount}
的划分,谢谢您的建议。它如何将timeoutCount与totalCall进行划分?您可以进行类似于${m3.totalCall/m3.timeoutCount}
的划分,谢谢您的建议。它如何将timeoutCount与totalCall进行划分?您可以进行类似于${m3.totalCall/m3.timeoutCount}