主介紹:?在職Java研發工程師、專注于程序設計、源碼分享、技術交流、專注于Java技術領域和畢業設計?
項目名稱
SSM框架基于JavaWeb在線投票系統的設計與實現源碼
視頻效果
SSM框架基于JavaWeb在線投票系統的設計與實現源碼
SSM框架基于JavaWeb在線投票系統的設計與實現源碼
系統說明
根據系統分析,將在線投票管理系統分為前臺功能模塊和后臺功能模塊。其中系統前臺功能實現用戶注冊、用戶登錄、瀏覽、投票、投票中心和投票歷史等功能。系統前臺功能如圖5-2所示:
?編輯
圖5-2 系統前臺功能模塊結構圖
用戶注冊:用戶填寫用戶名、密碼和性別,點擊注冊按鈕進行注冊。
用戶登錄:用戶填寫已經注冊的用戶名和密碼,點擊登錄按鈕進行登錄。
瀏覽:用戶可以瀏覽在線投票管理系統中公共開放內容。
投票:用戶選擇自己需要的投票,針對主題,勾選選項,進行投票操作。投票方式支持單選只能投一次、單選一天只能投一次、多選只能投一次、多選一天只能投一次等四種方式。
投票中心:在線投票管理系統展示所有投票主題供用戶選擇。
投票歷史:存儲用戶已經投票的歷史內容,用戶登陸后方可查看。
系統后臺功能實現以下功能,投票信息管理、詳細投票查看、用戶信息管理、投票信息統計和管理員登錄等功能。系統后臺功能如圖5-3所示:
?編輯
圖5-3 系統后臺功能模塊結構圖
投票信息管理:管理員進行投票信息管理,可以管理投票主題和投票選項。針對投票主題,可以添加投票主題(需要填寫主題名稱、主題類型、開始時間、結束時間和主題簡介)、查看主題、修改主題和刪除主題;針對投票選項管理,可以添加選項(需要填寫選項名稱和選擇所屬主題)、查看選項、修改選項和刪除選項。
詳細投票查看:管理員查看投票的詳細信息,以列表形式顯示,每條投票詳細信息包括:投票ID、用戶名、投票主題、投票選項、總投票數和投票時間等信息。
用戶信息管理:管理員進行用戶信息管理,可以添加用戶(需要填寫用戶名、密碼、性別和狀態)、查看用戶信息、修改用戶信息和刪除用戶。
投票信息統計:管理員進行投票信息統計,默認顯示所有的投票主題統計,輸入搜索主題名稱后顯示單個主題的投票統計。
管理員登錄:管理員輸入用戶名、密碼和驗證碼,點擊登錄按鈕,進行登錄操作。
環境需要
1.運行環境:最好是java jdk 1.8,我們在這個平臺上運行的。其他版本理論上也可以。
2.IDE環境:IDEA,Eclipse,Myeclipse都可以。推薦IDEA;
3.tomcat環境:Tomcat 7.x,8.x,9.x版本均可
4.硬件環境:windows 7/8/10 1G內存以上;或者 Mac OS;
5.數據庫:MySql 5.7版本;
6.是否Maven項目:否;
技術棧
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery
使用說明
1. 使用Navicat或者其它工具,在mysql中創建對應名稱的數據庫,并導入項目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse導入項目,Eclipse/MyEclipse導入時,若為maven項目請選擇maven;
若為maven項目,導入成功后請執行maven clean;maven install命令,然后運行;
3. 將項目中springmvc-servlet.xml配置文件中的數據庫配置改為自己的配置;
4. 運行項目,在瀏覽器中輸入http://localhost:8080/ 登錄
運行截圖
?編輯
?編輯
?編輯
?編輯
?編輯
?編輯
?編輯
?編輯
?編輯
?編輯
用戶管理控制層:
package com.houserss.controller;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.houserss.common.Const;
import com.houserss.common.Const.Role;
import com.houserss.common.ServerResponse;
import com.houserss.pojo.User;
import com.houserss.service.IUserService;
import com.houserss.service.impl.UserServiceImpl;
import com.houserss.util.MD5Util;
import com.houserss.util.TimeUtils;
import com.houserss.vo.DeleteHouseVo;
import com.houserss.vo.PageInfoVo;
/**
* Created by admin
*/
@Controller
@RequestMapping("/user/")
public class UserController {
@Autowired
private IUserService iUserService;
/**
* 用戶登錄
* @param username
* @param password
* @param session
* @return
*/
@RequestMapping(value="login.do",method=RequestMethod.POST)
@ResponseBody
public ServerResponse<User> login(User user,String uvcode, HttpSession session){
String code=(String)session.getAttribute("validationCode");
if(StringUtils.isNotBlank(code)) {
if(!code.equalsIgnoreCase(uvcode)) {
return ServerResponse.createByErrorMessage("驗證碼不正確");
}
}
ServerResponse<User> response=iUserService.login(user.getUsername(),user.getPassword());
if(response.isSuccess()){
session.setAttribute(Const.CURRENT_USER,response.getData());
}
return response;
}
}
管理員管理控制層:
package com.sxl.controller.admin;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sxl.controller.MyController;
@Controller("adminController")
@RequestMapping(value="/admin")
public class AdminController extends MyController {
@RequestMapping(value="/index")
public String frame(Model model, HttpServletRequest request)throws Exception {
return "/admin/index";
}
@RequestMapping(value="/main")
public String main(Model model, HttpServletRequest request)throws Exception {
return "/admin/main";
}
@RequestMapping(value="/tj1")
public String tj1(Model model, HttpServletRequest request)throws Exception {
String sql="select DATE_FORMAT(insertDate,'%Y-%m-%d') dates,sum(allPrice) price from t_order order by DATE_FORMAT(insertDate,'%Y-%m-%d') desc";
List<Map> list=db.queryForList(sql);
model.addAttribute("list", list);
System.out.println(list);
return "/admin/tj/tj1";
}
@RequestMapping(value="/password")
public String password(Model model, HttpServletRequest request)throws Exception {
return "/admin/password";
}
@RequestMapping(value="/changePassword")
public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {
Map admin=getAdmin(request);
if(oldPassword.equals(admin.get("password").toString())){
String sql="update t_admin set password=? where id=?";
db.update(sql, new Object[]{newPassword,admin.get("id")});
return renderData(true,"1",null);
}else{
return renderData(false,"1",null);
}
}
}
修改密碼業務邏輯:
package com.sxl.controller.admin;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sxl.controller.MyController;
@Controller("userController")
@RequestMapping(value="/user")
public class UserController extends MyController {
@RequestMapping(value="/index")
public String frame(Model model, HttpServletRequest request)throws Exception {
return "/user/index";
}
@RequestMapping(value="/main")
public String main(Model model, HttpServletRequest request)throws Exception {
return "/user/main";
}
@RequestMapping(value="/password")
public String password(Model model, HttpServletRequest request)throws Exception {
return "/user/password";
}
@RequestMapping(value="/changePassword")
public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {
Map user=getUser(request);
if(oldPassword.equals(user.get("password").toString())){
String sql="update t_user set password=? where id=?";
db.update(sql, new Object[]{newPassword,user.get("id")});
return renderData(true,"1",null);
}else{
return renderData(false,"1",null);
}
}
@RequestMapping(value="/mine")
public String mine(Model model, HttpServletRequest request)throws Exception {
Map user=getUser(request);Map map=db.queryForMap("select * from t_user where id=?",new Object[]{user.get("id")});model.addAttribute("map", map); return "/user/mine";
}
@RequestMapping(value="/mineSave")
public ResponseEntity<String> mineSave(Model model,HttpServletRequest request,Long id
,String username,String password,String name,String gh,String mobile) throws Exception{
int result=0;
String sql="update t_user set name=?,gh=?,mobile=? where id=?";
result=db.update(sql, new Object[]{name,gh,mobile,id});
if(result==1){
return renderData(true,"操作成功",null);
}else{
return renderData(false,"操作失敗",null);
}
}
}
通用管理模塊:
package com.sxl.controller;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import com.sxl.util.JacksonJsonUtil;
import com.sxl.util.StringUtil;
import com.sxl.util.SystemProperties;
public class BaseController {
public static final Long EXPIRES_IN=1000 * 3600 * 24 * 1L;// 1天
@Autowired
private SystemProperties systemProperties;
/**
* 獲得配置文件內容
*/
public String getConfig(String key) {
return systemProperties.getProperties(key);
}
/**
* 返回服務器地址 like http://192.168.1.1:8441/UUBean/
*/
public String getHostUrl(HttpServletRequest request) {
String hostName=request.getServerName();
Integer hostPort=request.getServerPort();
String path=request.getContextPath();
if (hostPort==80) {
return "http://" + hostName + path + "/";
} else {
return "http://" + hostName + ":" + hostPort + path + "/";
}
}
/***
* 獲取當前的website路徑 String
*/
public static String getWebSite(HttpServletRequest request) {
String returnUrl=request.getScheme() + "://"
+ request.getServerName();
if (request.getServerPort() !=80) {
returnUrl +=":" + request.getServerPort();
}
returnUrl +=request.getContextPath();
return returnUrl;
}
/**
* 初始化HTTP頭.
*
* @return HttpHeaders
*/
public HttpHeaders initHttpHeaders() {
HttpHeaders headers=new HttpHeaders();
MediaType mediaType=new MediaType("text", "html",
Charset.forName("utf-8"));
headers.setContentType(mediaType);
return headers;
}
/**
* 返回 信息數據
*
* @param status
* @param msg
* @return
*/
public ResponseEntity<String> renderMsg(Boolean status, String msg) {
if (StringUtils.isEmpty(msg)) {
msg="";
}
String str="{\"status\":\"" + status + "\",\"msg\":\"" + msg + "\"}";
ResponseEntity<String> responseEntity=new ResponseEntity<String>(str,
initHttpHeaders(), HttpStatus.OK);
return responseEntity;
}
/**
* 返回obj數據
*
* @param status
* @param msg
* @param obj
* @return
*/
public ResponseEntity<String> renderData(Boolean status, String msg,
Object obj) {
if (StringUtils.isEmpty(msg)) {
msg="";
}
StringBuffer sb=new StringBuffer();
sb.append("{");
sb.append("\"status\":\"" + status + "\",\"msg\":\"" + msg + "\",");
sb.append("\"data\":" + JacksonJsonUtil.toJson(obj) + "");
sb.append("}");
ResponseEntity<String> responseEntity=new ResponseEntity<String>(
sb.toString(), initHttpHeaders(), HttpStatus.OK);
return responseEntity;
}
/***
* 獲取IP(如果是多級代理,則得到的是一串IP值)
*/
public static String getIpAddr(HttpServletRequest request) {
String ip=request.getHeader("x-forwarded-for");
if (ip==null || ip.length()==0 || "unknown".equalsIgnoreCase(ip)) {
ip=request.getHeader("Proxy-Client-IP");
}
if (ip==null || ip.length()==0 || "unknown".equalsIgnoreCase(ip)) {
ip=request.getHeader("WL-Proxy-Client-IP");
}
if (ip==null || ip.length()==0 || "unknown".equalsIgnoreCase(ip)) {
ip=request.getRemoteAddr();
}
if (ip !=null && ip.length() > 0) {
String[] ips=ip.split(",");
for (int i=0; i < ips.length; i++) {
if (!"unknown".equalsIgnoreCase(ips[i])) {
ip=ips[i];
break;
}
}
}
return ip;
}
/**
* 國際化獲得語言內容
*
* @param key
* 語言key
* @param args
* @param argsSplit
* @param defaultMessage
* @param locale
* @return
*/
public static String getLanguage(String key, String args, String argsSplit,
String defaultMessage, String locale) {
String language="zh";
String contry="cn";
String returnValue=defaultMessage;
if (!StringUtil.isEmpty(locale)) {
try {
String[] localeArray=locale.split("_");
language=localeArray[0];
contry=localeArray[1];
} catch (Exception e) {
}
}
try {
ResourceBundle resource=ResourceBundle.getBundle("lang.resource",
new Locale(language, contry));
returnValue=resource.getString(key);
if (!StringUtil.isEmpty(args)) {
String[] argsArray=args.split(argsSplit);
for (int i=0; i < argsArray.length; i++) {
returnValue=returnValue.replace("{" + i + "}",
argsArray[i]);
}
}
} catch (Exception e) {
}
return returnValue;
}
}
?
到制作免費投票系統的話,首先自己要懂起碼的編程,然后在網上查看各種資料,其實也蠻簡單的,現在網上都有許多開源的免費投票系統代碼可以學習的,也可以直接使用的,小編自己就有一套免費投票系統的代碼,現在分享出來給大家學習下,如果你不的編程小白的話你就看可以直接把代碼封包制作成免費投票系統了。
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=投票系統” />
<META HTTP-EQUIV=”pragma” CONTENT=”no-cache”>
<META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache, must-revalidate”>
<META HTTP-EQUIV=”expires” CONTENT=http://www.aivote.com/ ”0″>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
</head>
<script language=”http://www.aivtp.com/4423.html javascript”>
function result(){
window.opener=’anyone’;
window.close();
}
</script>
<input name=’Action’ type=’hidden’ value=’Vote’>
<input name=’tj’http://www.aivtp.com/ type=”submit” value=”確認投票”>
</form></body>
</html>
這里要友情提示下,這套代碼大家雖然簡單,但是你如果是小白的話建議找懂的人給你看下,順便改成你自己需要的投票系統,還可以在代碼內添加驗證碼的代碼或者短信驗證碼,這個可以根據自己需求來決定。
于藝術生來說
色彩可能是生活的百分之八十
好的配色
?是任何作品能夠成功的關鍵
今天給大家的福利
“一份超全面的色彩網站”
快往下康康吧~~
· 正 · 文 · 來 · 啦 ·
1、COLORWISE
直通車:https://colorwise.io/
有大量的色彩搭配模板,大家可以挑選參考,對于作品集排版配色選擇是個不錯的網站。在Product Hunt中搜索投票最多的產品。
2、Color Hunt
直通車:https://colorhunt.co/
我們喜歡親切的稱呼它為:顏色狩獵,非常生動形象了有木有。Color Hunt是一個免費開放的色彩靈感平臺,擁有數千種時尚的手工挑選調色板。
3、HTML Color Codes
直通車:https://htmlcolorcodes.com/
這個網站可以直接獲取HTML顏色代碼、十六進制顏色代碼、RGB值和HSL值。
4、Duotones Effect Generator
直通車:https://medialoot.com/duotones/
雙色調效果發生器,十幾種經典雙色調可選,如今撞色超級流行,這個網站可以多多參考。
5、Generate — Coolors.co
直通車:https://coolors.co/
超快的配色方案發生器,可以在幾秒鐘之內建立、保持和分享完美的調色板
6、Colorable
直通車:https://colorable.jxnblk.com/
顏色對比器。
對比度是使對象(或其在圖像或顯示器中的表示)可區分的亮度或顏色的差異。在對現實世界的視覺感知中,對比度由對象和同一視野內的其他對象的顏色和亮度的差異確定。
7、HueSnap
直通車:https://www.huesnap.com/
也是可以快速建立調色板的網站
8、Eva Design System
直通車:https://eva.design/
可定制的設計系統可輕松適應你的品牌。適用于Sketch with Mobile和Web組件庫。
自由和開放源碼。
9、Grabient
直通車:https://www.grabient.com/
漸變色UI配色大全,還可以自由添加。
10、Color Designer
直通車:https://colordesigner.io/
通過顏色選擇器選擇一個基礎顏色,其他就交個它來處理啦。
11、Color Lisa
直通車:http://colorlisa.com/
來自世界上最偉大的藝術家的調色板杰作。
12、Color
直通車:https://www.canva.com/colors/
為任何項目尋找完美的顏色工具和資源。從調色板到你可能想要了解的有關顏色的所有內容。
13、Khroma
直通車:http://khroma.co/
設計師的AI顏色工具:發現,搜索和保存您喜愛的顏色組合。
14、Cool Backgrounds
直通車:https://coolbackgrounds.io/
Cool Backgrounds是一系列工具,可為博客,社交媒體和網站創建引人注目的彩色圖像。除了背景,生成的圖像可以用作桌面壁紙或裁剪為手機壁紙。
15、Eggradients
直通車:https://www.eggradients.com/
設計每年都在發展。最重要的設計,顏色,開始發展。我們準備了一個包含+200漸變背景顏色的漸變色調。
16、ColorKit
直通車:https://colorkit.io/
是一款很好用的顏色混合器
17、Color Leap - History’s Palettes
直通車:https://colorleap.app/home
選擇時代,看歷史顏色。
18、ColorSpace
直通車:https://mycolor.space/
19、Colors & Fonts
直通車:https://www.colorsandfonts.com/
20、WebGradients
直通車:https://webgradients.com/
WebGradients 是180個線性漸變的免費集合,你可以將其用作網站任何部分的內容背景。輕松復制CSS3 crossbrowser代碼并立刻使用它!
20、中國色彩
直通車:http://zhongguose.com/
中國色彩網 是中國傳統色彩的免費集合,當你選中一個色彩名稱時,網站背景則會變為該色,并會出現該色不同格式的代碼。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。