日期:2014-05-16  浏览次数:20392 次

JSTL格式化数据并计算展示报表
最终预览图:


private HashMap<String, String> ht3TypeTotal;
ht3TypeTotal = Thread3TypeTotal.ht3TypeTotal;


<%@ page
	language="java"
	import="java.util.*"
	pageEncoding="UTF-8"
%>
<%@ taglib
	uri="http://java.sun.com/jsp/jstl/fmt"
	prefix="fmt"
%>
<%@ taglib
	uri="http://java.sun.com/jsp/jstl/core"
	prefix="c"
%>
<div class="cl"></div>
<div class="ht_20"></div>
<div class="demo4_t"></div>
<div class="demo4_c">
	<div class="progresslt fl">
		<fmt:formatNumber
			type="percent"
			maxIntegerDigits="3"
			value="${(ht3TypeTotal['twitterP']+ht3TypeTotal['protalP']+ht3TypeTotal['bbsP'])/(ht3TypeTotal['twitterP']+ht3TypeTotal['protalP']+ht3TypeTotal['bbsP']+ht3TypeTotal['twitterN']+ht3TypeTotal['protalN']+ht3TypeTotal['bbsN'])}"
		/>
	</div>
	<div class="progressrt fl">
		<ul>
			<li class="progressrtlt">
				微博
			</li>
			<li class="progressrtrt">
				<c:choose>
					<c:when
						test="${ht3TypeTotal['twitterP'] + ht3TypeTotal['twitterN'] <= 0}"
					>
						<span
							style="width: 100%;"
							class="bar3 fr"
						></span>
					</c:when>
					<c:otherwise>
						<span
							style="width: ${ht3TypeTotal['twitterP']/(ht3TypeTotal['twitterP']+ht3TypeTotal['twitterN'])*100}%;"
							class="bar1lt fl"
						><fmt:formatNumber
								type="percent"
								maxIntegerDigits="3"
								value="${ht3TypeTotal['twitterP']/(ht3TypeTotal['twitterP']+ht3TypeTotal['twitterN']) >= 0.5 ? ht3TypeTotal['twitterP']/(ht3TypeTotal['twitterP']+ht3TypeTotal['twitterN']) : ''}"
							/> </span>
						<span
							style="width: ${ht3TypeTotal['twitterN']/(ht3TypeTotal['twitterP']+ht3TypeTotal['twitterN'])*100}%;"
							class="bar2 fr"
						><fmt:formatNumber
								type="percent"
								maxIntegerDigits="3"
								value="${ht3TypeTotal['twitterN']/(ht3TypeTotal['twitterP']+ht3TypeTotal['twitterN']) >= 0.5 ? ht3TypeTotal['twitterN']/(ht3TypeTotal['twitterP']+ht3TypeTotal['twitterN']) : ''}"
							/> </span>
					</c:otherwise>
				</c:choose>
			</li>
			<li class="progressrtlt">
				门户
			</li>
			<li class="progressrtrt">
				<c:choose>
					<c:when
						test="${ht3TypeTotal['protalP'] + ht3TypeTotal['protalN'] <= 0}"
					>
						<span
							style="width: 100%;"
							class="bar3 fr"
						></span>
					</c:when>
					<c:otherwise>
						<span
							style="width: ${ht3TypeTotal['protalP']/(ht3TypeTotal['protalP']+ht3TypeTotal['protalN'])*100}%;"
							class="bar1lt fl"
						><fmt:formatNumber
								type="percent"
								maxIntegerDigits="3"
								value="${ht3TypeTotal['protalP']/(ht3TypeTotal['protalP']+ht3TypeTotal['protalN']) >= 0.5 ? ht3TypeTotal['protalP']/(ht3TypeTotal['protalP']+ht3TypeTotal['protalN']) : ''}"
							/> </span>
						<span
							style="width: ${ht3TypeTotal['protalN']/(ht3TypeTotal['protalP']+ht3TypeTotal['protalN'])*100}%;"
							class="bar2 fr"
						><fmt:formatNumber
								type="percent"
								maxIntegerDigits="3"
								value="${ht3TypeTotal['protalN']/(ht3TypeTotal['protalP']+ht3TypeTotal['protalN']) >= 0.5 ? ht3TypeTotal['protalN']/(ht3TypeTotal['protalP']+ht3TypeTotal['protalN']) : ''}"
							/> </span>
					</c:otherwise>
				</c:choose>
			</li>
			<li class="progressrtlt">
				BBS
			</li>
			<li class="progressrtrt">
				<c:choose>
					<c:when test="${ht3TypeTotal['bbsP'] + ht3TypeTotal['bbsN'] <= 0}">
						<span
							style="width: 100%;"
							class="bar3 fr"
						></span>
					</c:when>
					<c:otherwise>
						<span