📄 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\">投票过程正常中!</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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -