⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voter.jsp

📁 这是我们做的一个网上购物系统,包手用户和管理员两大功能模块,采用jsp+servlet+java bean技术.
💻 JSP
字号:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import="com.qyg.shop.vote.*" %>
<%@page import="java.sql.Timestamp;"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'voter.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body bgcolor="D9EAFC">
    投票结果页面. <br>
   您对本网站的看法是:
    <%
    	String result = request.getParameter("vote");
    	if(result==null){
    		out.println("<font color='ff0000'>您还没投票!</font>");
    	}else if(result.equals("very good")){
    		out.println("<font color='ff0000'>非常喜欢</font>");
    	}else if(result.equals("good")){
    		out.println("<font color='ff0000'>还行</font>");
    	}else if(result.equals("common")){
    		out.println("<font color='ff0000'>一般</font>");
    	}else if(result.equals("bad")){
    		out.println("<font color='ff0000'>很差</font>");
    	}
     %>
     <%
     	long now = (new java.util.Date()).getTime();
		java.util.Date date = new java.util.Date(now);
		
     	VoteDAO dao = new VoteManageDAO();
     	int vote_class=1;
     	if(result!=null){     	
     		if(result.equals("very good")){
    			vote_class=1;
    		}else if(result.equals("good")){
    			vote_class=2;
    		}else if(result.equals("common")){
    			vote_class=3;
    		}else if(result.equals("bad")){
    			vote_class=4;
    		}
     		Vote vote = new Vote();
     		vote.setVote_class(vote_class);
     		dao.add(vote);
     	}
     	int result1 = dao.getVoteByClass(1);
     	int result2 = dao.getVoteByClass(2);
     	int result3 = dao.getVoteByClass(3);
     	int result4 = dao.getVoteByClass(4);
      %>
      <br><br>
     现在的投票结果为:<br>
     对本网站看法 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 
     人数<br><br>
     <%
     	out.print("<font color='red'>非常喜欢</font>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"+result1+"<br>");
     	out.print("<font color='red'>还行</font>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;"+result2+"<br>");
     	out.print("<font color='red'>一般</font>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;"+result3+"<br>");
     	out.print("<font color='red'>很差</font>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;"+result4+"<br>");
      %>
      
      <br><br>
      <a href="headpage.jsp">返回首页</a>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -