JavaWeb项目开发案例精粹-第2章投票系统-006view层

时间:2023-03-09 22:10:03
JavaWeb项目开发案例精粹-第2章投票系统-006view层

1.index.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>体育赛事投票系统</title>
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
<style type="text/css">
<!--
.STYLE14 {color: #FF0000}
.STYLE15 {font-family: tahoma; font-size: 11px;}
.STYLE17 {color: #003300}
-->
</style>
</head> <body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td width="642" align="left" valign="top"><table width="642" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="37" align="left" valign="top" background="images/menu.jpg">
<!--导航栏-->
<div style="padding-left:42px; padding-top:10px">
<a href="showVoteByChannel.action?channelID=1" class="style2" style="text-decoration:none ">NBA</a>
<img src="data:images/spacer.gif" width="74" height="1">
<a href="showVoteByChannel.action?channelID=2" class="style2" style="text-decoration:none ">CBA</a>
<img src="data:images/spacer.gif" width="55" height="1">
<a href="showVoteByChannel.action?channelID=3" class="style2" style="text-decoration:none ">足球世界杯</a>
<img src="data:images/spacer.gif" width="33" height="1">
<a href="showVoteByChannel.action?channelID=4" class="style2" style="text-decoration:none ">中超</a>
<img src="data:images/spacer.gif" width="68" height="1">
<a href="showVoteByChannel.action?channelID=5" class="style2" style="text-decoration:none ">英超</a>
<img src="data:images/spacer.gif" width="64" height="1">
<a href="showVoteByChannel.action?channelID=6" class="style2" style="text-decoration:none ">F1</a>
</div>
</td>
</tr>
<tr>
<td align="left" valign="top"><table width="642" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top">
<td width="427" height="100%" align="right"><table width="426" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><table width="426" border="0" cellpadding="0" cellspacing="0" background="images/line_1.jpg">
<tr>
<td height="22" align="left" valign="middle" background="images/kattle_1.jpg" class="style2">&nbsp;&nbsp;最新投票</td>
</tr>
<tr>
<td height="518" align="left" valign="top"><div style="padding-left:18px; padding-top:16px; padding-bottom:20px">
<s:actionerror/>
<s:iterator value="#request.voteResultList" var="voteResult">
<p class="style2">${voteResult.vote.voteName}</p>
<form action="doVote.action" method="post">
<p class="style2">
<s:iterator value="#voteResult.voteOptions" var="voteOption">
<input type="radio" name="voteOptionID" value="${voteOption.voteOptionID}">${voteOption.voteOptionName}<br>
</s:iterator>
<input type="radio" name="voteOptionID" value="0">其它<br>
<input type="text" name="otherOption">
<input type="hidden" name="voteID" value="${voteResult.vote.voteID}">
<input type="hidden" name="channelID" value="${voteResult.vote.channelID}">
<a href="voteResult?voteID=${voteResult.vote.voteID}">查看投票结果</a>
</p>
<p>
<input type="submit" value="投票">
<input type="reset" value="重置">
</p>
</form>
</s:iterator>
<s:if test="#request.voteResultList.size == 0">
没有任何投票内容!
</s:if>
</div>
<div align="center" style="font-size: 12px">
<s:if test="#request.page.hasPrePage">
<a href="showVoteByChannel?channelID=${channelID}&&currentPage=1">首页</a> |
<a href="showVoteByChannel?channelID=${channelID}&&currentPage=${page.currentPage -1 }">上一页</a>
</s:if>
<s:else>
首页 | 上一页
</s:else>
<s:if test="#request.page.hasNextPage">
<a href="showVoteByChannel?channelID=${channelID}&&currentPage=${page.currentPage + 1 }">下一页</a> |
<a href="showVoteByChannel?channelID=${channelID}&&currentPage=${page.totalPage }">尾页</a>
</s:if>
<s:else>
下一页 | 尾页
</s:else>
</div>
</td>
</tr>
<tr>
<td align="left" valign="top"><img src="data:images/kettle_2.jpg" width="426" height="2"></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="215" height="100%" align="right"><table width="203" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><table width="203" height="613" border="0" cellpadding="0" cellspacing="0" background="images/line_3.jpg">
<tr>
<td height="22" align="left" valign="middle" background="images/kettle_5.jpg" class="style9 STYLE14">&nbsp;<span class="STYLE15">&nbsp;<span class="STYLE17">热门投票</span></span></td>
</tr>
<tr>
<td align="left" valign="top"><div style="padding-left:19px; padding-top:14px; padding-bottom:10px"></div>
<ol>
<li class="style7">你最喜欢的NBA球员</li>
<li class="style7">你最喜欢的NBA中锋</li>
</ol></td>
</tr>
<tr>
<td height="2" align="left" valign="top"><img src="data:images/bot_1.jpg" width="203" height="2"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="11" align="left" valign="top"><img src="data:images/spacer.gif" width="1" height="11"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="12" align="left" valign="top"><img src="data:images/spacer.gif" width="1" height="12"></td>
</tr>
<tr>
<td align="left" valign="top" background="images/rep_1.jpg" style="background-repeat:repeat-x; background-position:top left "><div align="center" style="padding-top:14px"></div>
<div style="padding-left:5px; padding-top:3px">
<div align="center" class="style8">体育赛事投票系统 &copy;2009-2010 </div>
</div></td>
</tr>
</table></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="642" align="left" valign="top">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

2.admin/addVote.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>新增投票</title>
<script type="text/javascript" language="javascript">
var i = 4;
function addVoteOption(){
var voteP = document.getElementById("voteOptionList");
var inputText = document.createTextNode("选项" + (i++) +"名称:");
voteP.appendChild(inputText);
var inputP = document.createElement("input");
inputP.type="text";
inputP.name="voteOption";
voteP.appendChild(inputP);
var brP = document.createElement("<br>");
voteP.appendChild(brP);
}
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15" height="30"><img src="data:images/tab_03.gif" width="15" height="30" /></td>
<td width="1101" background="images/tab_05.gif"><img src="data:images/311.gif" width="16" height="16" /> <span style="font-size: 12px">新增投票</span></td>
<td width="281" background="images/tab_05.gif"></td>
<td width="14"><img src="data:images/tab_07.gif" width="14" height="30" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="9" background="images/tab_12.gif">&nbsp;</td>
<td bgcolor="#f3ffe3">
<div style="padding-left: 100px;padding-top: 10px;font-size: 12px">
<form action="addVote.action" method="post" name="addForm">
选择投票频道:<select name="channel">
<option value="1">NBA</option>
<option value="2">CBA</option>
<option value="3">足球世界杯</option>
<option value="4">中超</option>
<option value="5">英超</option>
<option value="6">F1</option>
</select><br/>
请输入投票名称:<input type="text" name="voteName"/><br/>
<div id="voteOptionList">
选项1名称:<input type="text" name="voteOption"/><br/>
选项2名称:<input type="text" name="voteOption"/><br/>
选项3名称:<input type="text" name="voteOption"/><br/>
</div>
<input type="button" value="新增投票选项" onclick="addVoteOption()"/>
<input type="submit" value="发布"/>
<input type="reset" value="重置"/>
</form>
</div>
</td>
<td width="9" background="images/tab_16.gif">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td height="29"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15" height="29"><img src="data:images/tab_20.gif" width="15" height="29" /></td>
<td background="images/tab_21.gif">&nbsp;</td>
<td width="14"><img src="data:images/tab_22.gif" width="14" height="29" /></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>

3.admin/index.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>投票系统后台管理</title>
</head> <frameset rows="10,*,24" cols="*" framespacing="0" frameborder="no" border="0">
<frame src="top.html" name="topFrame" scrolling="no" noresize="noresize" id="topFrame" />
<frame src="center.html" name="mainFrame" id="mainFrame" />
<frame src="down.html" name="bottomFrame" scrolling="no" noresize="noresize" id="bottomFrame" />
</frameset>
<noframes><body>
</body>
</noframes></html>

4.admin/showVote.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示投票</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
overflow:hidden;
}
.STYLE1 {font-size: 12px}
.STYLE4 {
font-size: 12px;
color: #1F4A65;
font-weight: bold;
} a:link {
font-size: 12px;
color: #06482a;
text-decoration: none; }
a:visited {
font-size: 12px;
color: #06482a;
text-decoration: none;
}
a:hover {
font-size: 12px;
color: #06482a;
text-decoration: none;
}
a:active {
font-size: 12px;
color: #06482a;
text-decoration: none;
}
.STYLE7 {font-size: 12}
-->
</style></head> <body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15" height="30"><img src="data:images/tab_03.gif" width="15" height="30" /></td>
<td width="1101" background="images/tab_05.gif"><img src="data:images/311.gif" width="16" height="16" /> <span class="STYLE4">投票管理</span></td>
<td width="281" background="images/tab_05.gif">&nbsp;</td>
<td width="14"><img src="data:images/tab_07.gif" width="14" height="30" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="9" background="images/tab_12.gif">&nbsp;</td>
<td bgcolor="#f3ffe3"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98" onmouseover="changeto()" onmouseout="changeback()">
<tr>
<td width="8%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">投票序号</div></td>
<td width="24%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">投票名</div></td>
<td width="10%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">投票选项1</div></td>
<td width="14%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">投票选项2</div></td>
<td width="24%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">投票选项3</div></td>
<td width="7%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">删除</div></td>
</tr> <!--循环输出投票数据 -->
<s:iterator value="#request.voteResultList" var="voteResult">
<tr>
<td height="18" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1">${voteResult.vote.voteID}</div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1">${voteResult.vote.voteName}</div></td>
<!-- 只输出前三个投票选项 -->
<s:subset source="#voteResult.voteOptions" id="subvoteOptions" start="0" count="3"></s:subset>
<s:iterator value="#attr.subvoteOptions" var="voteOption">
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1">${voteOption.voteOptionName}</div></td>
</s:iterator>
<td height="18" bgcolor="#FFFFFF"><div align="center"><span class="STYLE2"><img src="data:images/010.gif" width="9" height="9" /> </span><span class="STYLE1">[</span><a href="deleteVote.action?voteID=${voteResult.vote.voteID}">删除</a><span class="STYLE1">]</span></div></td>
</tr>
</s:iterator>
</table></td>
<td width="9" background="images/tab_16.gif">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td height="29"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15" height="29"><img src="data:images/tab_20.gif" width="15" height="29" /></td>
<td background="images/tab_21.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" height="29" nowrap="nowrap"><span class="STYLE1">共${page.totalCount}条纪录,当前第${page.currentPage}/${page.totalPage}页,每页${page.everyPage}条纪录</span></td>
<td width="75%" valign="top" class="STYLE1"><div align="right">
<table width="215" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<s:if test="#request.page.hasPrePage">
<td width="62" height="22" valign="middle">
<div align="right">
<a href="showVote.action?currentPage=1"><img src="data:images/first.gif" border="0"/></a>
</div></td>
<td width="50" height="22" valign="middle">
<div align="right">
<a href="showVote.action?currentPage=${page.currentPage - 1}"><img src="data:images/back.gif" border="0"/></a>
</div></td>
</s:if>
<s:else>
<td width="62" height="22" valign="middle">
<div align="right">
<img src="data:images/first.gif" border="0"/>
</div></td>
<td width="50" height="22" valign="middle">
<div align="right">
<img src="data:images/back.gif" border="0"/>
</div></td>
</s:else>
<s:if test="#request.page.hasNextPage">
<td width="54" height="22" valign="middle">
<div align="right">
<a href="showVote.action?currentPage=${page.currentPage+1}"><img src="data:images/next.gif" border="0"/></a>
</div></td>
<td width="49" height="22" valign="middle">
<div align="right">
<a href="showVote.action?currentPage=${page.totalPage}"><img src="data:images/last.gif" border="0"/></a>
</div></td>
</s:if>
<s:else>
<td width="54" height="22" valign="middle">
<div align="right">
<img src="data:images/next.gif" border="0"/>
</div></td>
<td width="49" height="22" valign="middle">
<div align="right">
<img src="data:images/last.gif" border="0"/>
</div></td>
</s:else>
</tr>
</table>
</div></td>
</tr>
</table></td>
<td width="14"><img src="data:images/tab_22.gif" width="14" height="29" /></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<s:debug></s:debug>

5.admin/center.html

 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
overflow:hidden;
}
-->
</style></head> <body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed">
<tr>
<td background="images/main_40.gif" style="width:3px;">&nbsp;</td>
<td width="177" style="border-right:solid 1px #9ad452;"><iframe name="I2" height="100%" width="177" border="0" frameborder="0" src="left.html">
浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></td>
<td><iframe name="I1" src="showVote.action" height="100%" width="100%" border="0" frameborder="0">
浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></td>
<td background="images/main_42.gif" style="width:3px;">&nbsp;</td>
</tr>
</table>
</body>
</html>

6.admin/down.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE1 {
color: #43860c;
font-size: 12px;
}
-->
</style></head> <body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24" background="images/main_47.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="29" height="24"><img src="data:images/main_45.gif" width="29" height="24" /></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="369"><span class="STYLE1">版本 2008V1.0 </span></td>
<td width="814" class="STYLE1">&nbsp;</td>
<td width="185" nowrap="nowrap" class="STYLE1"><div align="center"><img src="data:images/main_51.gif" width="12" height="12" /> 如有疑问请与技术人员联系</div></td>
</tr>
</table></td>
<td width="14"><img src="data:images/main_49.gif" width="14" height="24" /></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>

7.admin/left.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE2 {color: #43860c; font-size: 12px; } a:link {font-size:12px; text-decoration:none; color:#43860c;}
a:visited {font-size:12px; text-decoration:none; color:#43860c;}
a:hover{font-size:12px; text-decoration:none; color:#FF0000;}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
} function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
} function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
} function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head> <body onload="MM_preloadImages('images/main_26_1.gif','images/main_29_1.gif','images/main_31_1.gif')">
<table width="177" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed">
<tr>
<td height="26" background="images/main_21.gif">&nbsp;</td>
</tr>
<tr>
<td height="80" style="background-image:url(images/main_23.gif); background-repeat:repeat-x;"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="45"><div align="center"><a href="#"><img src="data:images/main_26.gif" name="Image1" width="40" height="40" border="0" id="Image1" onmouseover="MM_swapImage('Image1','','images/main_26_1.gif',1)" onmouseout="MM_swapImgRestore()" /></a></div></td>
<td><div align="center"><a href="#"><img src="data:images/main_28.gif" name="Image2" width="40" height="40" border="0" id="Image2" onmouseover="MM_swapImage('Image2','','images/main_29_1.gif',1)" onmouseout="MM_swapImgRestore()" /></a></div></td>
</tr>
<tr>
<td height="25"><div align="center" class="STYLE2"><a href="addVote.jsp" target="I1">新增投票</a></div></td>
<td><div align="center" class="STYLE2"><a href="showVote.action" target="I1">投票管理</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td style="line-height:4px; background:url(images/main_38.gif)">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>

8.admin/top.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE1 {
color: #43860c;
font-size: 12px;
}
-->
</style></head> <body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed;">
<tr>
<td height="9" style="line-height:9px; background-image:url(images/main_04.gif)">&nbsp;</td>
</tr>
</table> </body>
</html>

9.