首页 ┆ 网站地图 ┆ 在线留言 ┆ 游戏资讯 ┆ 资源下载 ┆ 端午节祝福 ┆ 迅雷在线影视 ┆淘宝手机在线充值 ┆淘宝游戏点卡充值 
设为首页
加入收藏
联系我们
高级搜索
您当前的位置: 主页>JAVA专区>STRUTS>Struts+hibernate实现投票系统代码实例
Struts+hibernate实现投票系统代码实例
来源: 发布时间:2008-04-01 发布人: 浏览: 人次   字体: [ ]  

 index.jsp

<%@page contentType="text/html;charset=gb2312" %>
<%@ taglib prefix="vote" uri="http://hxex.cn/vote" %>

<html>
<head>
    
<title>投票系统</title>
</head>
<body>
    
<center>
    
<table>
        
<tr>
            
<td>
                
<img src="img/index.gif" width="150">
            
</td>
            
<td>
                
<h1>请您投票</h1>
                ${vote:display('salary')}
            
</td>
        
</tr>
    
</table>
    
</center>
</body>
</html>

 ote_add_update.jsp

<%@page contentType="text/html;charset=gb2312" %>
<%@ taglib prefix="vote" uri="http://hxex.cn/vote" %>
<html>
<head>
<% 
   
String context=request.getContextPath();
 
%>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
    
<title>发布投票</title>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
  
function checkValid(form){
    
var checks=[[form.name,"请输入投票标识"],[form.text,"请输入投票名称"]];
    
if(!isRequired(checks)){
    
return false;
    }

    
return true;
   
  }

  
function gomanager(){
    window.location.href
="<%=context%>/voteManage.do"
  }

</script>    
</head>
<center>
    
<h1>发布投票</h1>
    
<p>
    
<table>
        
<form method="post" name="main" action="<%=context%>/voteSave.do" onsubmit="return checkValid(this);">
        
<tr>
            
<td width="100">投票名称</td>
            
<td><input type="text" name="name" value="${vote.name}"> *</td>
        
</tr>
        
<tr>
            
<td>投票标识</td>
            
<td><input type="text" name="title" value="${vote.title}">*</td>
        
</tr>
        
<tr>
            
<td>投票类型</td>
            
<td>
                
<select name="votetype">
                    ${vote:votetypeoptions(vote.votetype) }
                
</select>
            
</td>
        
</tr>
        
<tr>
            
<td>图形类型</td>
            
<td>
                
<select name="pictype">
                   ${vote:pictypeoptions(vote.pictype) } 
                
</select>
            
</td>
        
</tr>
        
<tr>
            
<td colspan="2" align="center">
                
<input type="hidden" name="id" value="${vote.id }">
                
<input type="submit" value="保存">&nbsp;&nbsp;
                
<input type="reset" value="重填">&nbsp;&nbsp;
                
<input type="button" value="返回" onclick="gomanager();">
            
</td>
        
</tr>
        
</form>
    
</table>
    
<p>
    
<img src="img/voteadd.gif" width="200">
</center>
</html>

 vote_list.jsp

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="http://hxex.cn/vote" prefix="vote" %>
<%@page contentType="text/html;charset=gb2312" %>

<html>
<head>
<% 
   
String context=request.getContextPath();
 
%>
    
<title>投票管理系统</title>
</head>
<body>
<center>
    
<h1>投票管理系统</h1>
    
<table border="1">
        
<tr>
            
<td colspan="5"><font color="red">${msg}</font></td>
        
</tr>
        
<tr>
            
<td align="center">投票标识</td>
            
<td align="center">投票名称</td>
            
<td align="center">投票类型</td>
            
<td align="center">图形类型</td>
            
<td align="center">操作类型</td>
        
</tr>
        
        
<c:forEach var="vote" items="${votes}">
        
<tr>
            
<td>${vote.name}</td>
            
<td>${vote.title}</td>
            
<td>${vote:votetype(vote.votetype)}</td>
            
<td>${vote:pictype(vote.pictype)}</td>
            
<td align="center">
                  
<href="<%=context %>/voteEdit.do?id=${vote.id}">修改投票</a>
                
<href="<%=context %>/voteDelete.do?id=${vote.id}">删除投票</a>
                
<href="<%=context %>/voteitemList.do?id=${vote.id}">修改选项</a>
            
</td>
        
</tr>
        
</c:forEach>
    
</table>
    
<p>
    
<href="vote_add_update.jsp">发布投票</a>
    
<p>
    
<img src="img/manager.gif" width="300">
</center>
</body>    
</html>

 vote_result.jsp

<%@page contentType="text/html;charset=gb2312" %>
<%@ taglib prefix="vote" uri="http://hxex.cn/vote" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    
<title>投票结果</title>
</head>
<body>
    
<center>
        
<h1>${vote.title}</h1>
        
<h3>投票结果</h3>
         
<img src="/VoteManager/chart?id=${vote.id}">
        
<table width="300" border="1">
            
<tr>
                
<td align="center">选项</td>
                
<td align="center">结果</td>
            
</tr>
            
<c:forEach var="voteitem" items="${vote.voteitems}">
            
<tr>
                
<td>${voteitem.title}</td>
                
<td>${voteitem.votenum}</td>
            
</tr>
            
</c:forEach>
            
<tr>
                
<td colspan="2" align="center">
                    
<href="index.jsp">返回</a>
                
</td>
            
</tr>
        
</table>
    
</center>
</body>
</html>

voteitem_add_update.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="vote" uri="http://hxex.cn/vote" %>
<%@page contentType="text/html;charset=gb2312" %>
<%@page isELIgnored="false"%>

<html>
<head>
<%
  
String context=request.getContextPath();
 
%>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
  
function checkValid(form){
    
var checks=[[form.title,"请输入投票选项"],[form.votenum,"请输入票数"]];
    
if(isRequired(checks)){
      
return true;
    }

    
return false;
  }

  
function gomanager(){
    window.location.href
="<%=context%>/voteManage.do"
  }

</script>    

    
<title>维护投票条目</title>

</head>
<body>
    
<center>
        
<h1>维护投票条目</h1>
        
<table>
            
<tr>
                
<td><font color="red">${msg}</font></td>
                
<td valign="bottom" rowspan="13">
                    
<img src="img/voteitem.gif" width="150">
                
</td>
            
</tr>
            
<tr>
                
<td>&nbsp;</td>
            
</tr>
            
<tr>
                
<td align="center">投票信息</td>
            
</tr>
            
<tr>
                
<td>投票标识:${vote.name }</td>
            
</tr>
            
<tr>
                
<td>投票名称:${vote.title }</td>
            
</tr>
            
<tr>
                
<td>投票类型:${vote:votetype(vote.votetype) }</td>
            
</tr>
            
<tr>
                
<td>图形类型:${vote:pictype(vote.pictype) } </td>
            
</tr>
            
<tr>
                
<td>&nbsp;</td>
            
</tr>
            
<c:if test="${!empty vote.voteitems}">
            
<tr>
                
<td align="center">已经存在的投票选项</td>
            
</tr>
            
<tr>
                
<td>
                    
<table width="100%" border="1">
                        
                        
<tr>
                            
<td align="center">选项</td>
                            
<td align="center">票数</td>
                            
<td align="center">操作</td>
                        
</tr>
                        
<c:forEach var="voteitem" items="${vote.voteitems}">
                        
<tr>
                            
<td>${voteitem.title}</td>
                            
<td>${voteitem.votenum}</td>
                            
<td align="center">
                                
<href="<%=context %>/voteitemEdit.do?id=${voteitem.id}">修改选项</a>&nbsp;&nbsp;
                                
<href="<%=context %>/voteitemDelete.do?id=${voteitem