【JSP开源代码栏目提醒】:网学会员JSP开源代码为您提供showvote.jsp参考,解决您在showvote.jsp学习中工作中的难题,参考学习。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.text.NumberFormat,java.util.*"%>
<%@ page import="com.wxpn.tutorial.servlet.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>鎶曠エ缁撴灉</title>
</head>
<body>
<%Question question = (Question) request.getAttribute("question");
Collection c = question.getItems();
Date startTime = question.getStartime();
Date endTime = question.getEndtime();
Date now = new Date();
String errorMsg = "<font color=\"#FF0000\">鎶曠エ杩囩▼姝e父涓?</font>";
int status = 1;
if (now.before(startTime)) {
errorMsg = "<font color=\"#FF0000\">鎶曠エ灏氭湭寮濮嬶紒</font>";
status = 0;
} else if (now.after(endTime)) {
errorMsg = "<font color=\"#FF0000\">鎶曠エ宸茬粡缁撴潫锛?/font>";
status = 0;
} else if (question.getActive() == 0) {
errorMsg = "<font color=\"#FF0000\">鎶曠エ杩囩▼宸插叧闂紒</font>";
status = 0;
}
NumberFormat nf = NumberFormat.getPercentInstance();
%>
<table width="80%" border="0" align="center">
<tr>
<td colspan="3" align="center" bgcolor="#CCFFCC"><b> <%=errorMsg%> </b></td>
</tr>
</table>
<table width="80%" border="0" align="center">
<tr>
<td colspan="3" align="center" bgcolor="#C0C0C0"><b> <font
color="#0000FF">鎶曠エ缁撴灉</font></b></td>
</tr>
</table>
<table width="80%" border="0" align="center">
<tr>
<td colspan="3" align="center" bgcolor="#FFCC99"><u><b>涓婚锛?%=question.getTitle()%></b></u></td>
</tr>
<tr>
<td colspan="3" align="center" valign="middle">鐜板湪鎬诲叡鎶曠エ:<b><font
color="#0000FF"><%=question.getVotecount()%></font></b></td>
</tr>
</table>
<table width="80%" border="0" align="center">
<%if ((c != null) && (question.getVotecount() > 0)) {
Iterator iterator = c.iterator();
int i = 1;
Item item = null;
while (iterator.hasNext()) {
item = (Item) iterator.next();
%>
<tr>
<td align="left" bgcolor="#CCCCFF">[<%=i%>] <%=item.getOptions()%></td>
<td align="left" bgcolor="#CCCCFF"><img border="0" src="1.jpg"
height=14
width="<%=((double)item.getVote()*100/question.getVotecount())%>"><%=nf.format((double) item.getVote()
/ question.getVotecount())%>(<%=item.getVote()%>)</td>
</tr>
<%i++;
}
}%>
</table>
<table width="80%" border="0" align="center">
<tr>
<td align="center" valign="middle"><%if (status == 1) {
%> <a href="ShowVoteServlet?id=<%=question.getId()%>&page=vote.jsp">鎴戣鎶曠エ</a>|
<%}
%> <a href="index.jsp">杩斿洖棣栭〉</a></td>
</tr>
</table>
</body>
</html>