基于javaweb的问卷调查系统(java+ssm+layui+jsp+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的问卷调查系统(java+SSM+layui+JSP+Mysql)

项目介绍

这是一个基于SpringMVC+Spring+MyBatis的SSM问卷调查系统。 管理端权限 管理员信息CURD 制作调查问卷 发布调查问卷 统计调查结果 统计报表展示 用户端权限 填写问卷

环境需要

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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目  6.数据库:MySql 5.7等版本均可;

技术栈

  1. 后端:Spring Springmvc Mybatis  2. 前端:JSP+css+javascriipt+jQuery+layui

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat, 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置,然后运行; 4.运行项目,在浏览器中输入http://localhost:8080/survey 管理员用户名密码:admin/123456

登录控制层:

@Controller

public class LoginController {

@Autowired

private AdminService adminService;

@GetMapping(“/login”)

public String v_login(){

return “login”;

@PostMapping(“/login”)

@ResponseBody

public Map<String, Object> login(@RequestBody Map<String,Object> map, HttpServletRequest request){

String account = map.get(“account”)+“”;

String password = map.get(“password”)+“”;

if(Strings.isNullOrEmpty(account) || Strings.isNullOrEmpty(password)){

return MapControl.getInstance().error(“用户名或密码不能为空”).getMap();

Admin admin = adminService.login(account, MD5Utils.getMD5(password));

if(admin != null){

SessionUtils.setAdmin(request,admin);

return MapControl.getInstance().success().getMap();

}else{

return MapControl.getInstance().error(“用户名或密码错误”).getMap();

@GetMapping(“/pwd”)

public String pwd(){

return “pwd”;

@PostMapping(“/pwd”)

@ResponseBody

public Map<String,Object> pwd(Integer id,String type,String sourcePwd,String newPwd){

Admin user = adminService.detail(id);

if(user.getPassword().equals(MD5Utils.getMD5(sourcePwd))){

Admin entity = new Admin();

entity.setId(id);

entity.setPassword(MD5Utils.getMD5(newPwd));

int update = adminService.update(entity);

if(update>0){

return MapControl.getInstance().success().getMap();

}else{

return MapControl.getInstance().error().getMap();

}else{

return MapControl.getInstance().error(“原密码错误”).getMap();

问卷管理控制层:

@Controller

@RequestMapping(“/survey”)

public class SurveyController {

@Autowired

private SurveyService surveyService;

@Autowired

private QuestionService questionService;

@GetMapping(“/create”)

public String v_create(){

return “survey/add”;

@PostMapping(“/create”)

@ResponseBody

public Map<String,Object> create(@RequestBody Survey survey, HttpServletRequest request){

Admin currAdmin = SessionUtils.getAdmin(request);

survey.setCreator(currAdmin.getId());

survey.setState(Survey.state_create);

survey.setAnon(survey.getAnon()!=null?0:1);

int result = surveyService.create(survey);

if(result<=0){

//失败的情况下

return MapControl.getInstance().error().getMap();

return MapControl.getInstance().success().getMap();

@PostMapping(“/delete”)

@ResponseBody

public Map<String,Object> delete(String ids){

int result = surveyService.deleteBatch(ids);

if(result<=0){

//失败的情况下

return MapControl.getInstance().error().getMap();

return MapControl.getInstance().success().getMap();

@PostMapping(“/update”)

@ResponseBody

public Map<String, Object> update(@RequestBody Survey survey){

survey.setAnon(survey.getAnon()!=null?0:1);

int result = surveyService.update(survey);

if(result<=0){

//失败的情况下

return MapControl.getInstance().error().getMap();

return MapControl.getInstance().success().getMap();

@GetMapping(“/list”)

public String list(){

return “survey/list”;

@PostMapping(“/query”)

@ResponseBody

public Map<String,Object> query(@RequestBody Survey survey, ModelMap modelMap){

List list = surveyService.query(survey);

//创建者信息写入survey对象

for (Survey entity : list) {

entity.setAdmin(SystemInit.adminMap.get(entity.getCreator()));

Integer count = surveyService.count(survey);

return MapControl.getInstance().page(list,count).getMap();

@GetMapping(“/detail”)

public String detail(Integer id,ModelMap modelMap){

Survey survey = surveyService.detail(id);

modelMap.addAttribute(“survey”,survey);

return “survey/update”;

@GetMapping(“/question”)

public String question(Integer id,ModelMap modelMap){

Survey survey = surveyService.detail(id);

modelMap.addAttribute(“survey”,survey);

return “survey/question”;

@GetMapping(“/preview/{id}”)

public String preview(@PathVariable(“id”) Integer id,ModelMap modelMap){

Survey survey = surveyService.detail(id);

Question question = new Question();

question.setSurveyId(survey.getId());

//查询一个问卷中的所有问题及选项

List questions = questionService.query(question);

//将问题设置为survey的属性

survey.setQuestions(questions);

modelMap.addAttribute(“survey”,survey);

return “survey/preview”;

@RequestMapping(value = “/upload”,method = RequestMethod.POST)

public String upload(Integer id, @RequestParam(“file”) MultipartFile multipartFile, HttpServletRequest request){

//上传的位置

String path = request.getSession().getServletContext().getRealPath(“/upload/”);

//判断该路径是否存在

File file = new File(path);

if (!file.exists()) {

file.mkdirs();

//上传文件项

String filename = multipartFile.getOriginalFilename();

String uuid = UUID.randomUUID().toString().replace(“-”, “”);

String saveName = uuid + “_” + filename.substring(filename.lastIndexOf(File.separator) + 1);

try {

multipartFile.transferTo(new File(path, saveName));

Survey survey = new Survey();

survey.setId(id);

survey.setBgimg(saveName);

surveyService.update(survey);

} catch (IOException e) {

e.printStackTrace();

return “redirect:preview/”+id;

@PostMapping(“/publish”)

@ResponseBody

public Map<String,Object> publish(Integer id,HttpServletRequest request){

Survey param = surveyService.detail(id);

if(!Survey.state_exec.equals(param.getState())){

return MapControl.getInstance().error(“操作失败,当前问卷未在执行中!”).getMap();

String uuid = “/dy/”+UUID.randomUUID().toString();

Survey survey = new Survey();

survey.setId(id);

//http://localhost:8080/survey/ieieas-asdf-asdf-3-asd-f-asdf

String url = “http://”+request.getServerName()+ “:” + request.getServerPort() + request.getContextPath()+uuid;

survey.setUrl(url);

surveyService.update(survey);

return MapControl.getInstance().success().getMap();

@PostMapping(“/submit”)

@ResponseBody

public Map<String,Object> submit(@RequestBody List<Map<String,Object>> list){

List optList = new ArrayList();

List txtList = new ArrayList();

String uuid = UUID.randomUUID().toString();

for (Map<String, Object> stringObjectMap : list) {

if(object2String(stringObjectMap.get(“type”)).equals(“1”) || object2String(stringObjectMap.get(“type”)).equals(“2”)){

List opts = (List) stringObjectMap.get(“opts”);

for (Object opt : opts) {

AnswerOpt answerOpt = new AnswerOpt();

answerOpt.setQuestionId(object2Integer(stringObjectMap.get(“questionId”)));

answerOpt.setSurveyId(object2Integer(stringObjectMap.get(“surveyId”)));

answerOpt.setType(object2String(stringObjectMap.get(“type”)));

answerOpt.setOptId(object2Integer(opt));

answerOpt.setCreateTime(new Date());

answerOpt.setVoter(uuid);

optList.add(answerOpt);

if(object2String(stringObjectMap.get(“type”)).equals(“3”) || object2String(stringObjectMap.get(“type”)).equals(“4”)){

AnswerTxt answerTxt = new AnswerTxt();

answerTxt.setQuestionId(object2Integer(stringObjectMap.get(“questionId”)));

answerTxt.setSurveyId(object2Integer(stringObjectMap.get(“surveyId”)));

answerTxt.setResult(object2String(stringObjectMap.get(“result”)));

answerTxt.setCreateTime(new Date());

answerTxt.setVoter(uuid);

txtList.add(answerTxt);

surveyService.submit(optList,txtList);

return MapControl.getInstance().success().getMap();

@GetMapping(“/query_detail/{id}”)

public String query_detail(@PathVariable(“id”) Integer id,ModelMap modelMap){

Survey survey = surveyService.detail(id);

Question question = new Question();

question.setSurveyId(survey.getId());

//查询一个问卷中的所有问题及选项

List questions = questionService.query(question);

//将问题设置为survey的属性

survey.setQuestions(questions);

//总投票人数

AnswerOpt answerOpt = new AnswerOpt();

answerOpt.setSurveyId(id);

List answerOpts = surveyService.queryAnswerOpt(answerOpt);

Set set = new HashSet();

for (AnswerOpt opt : answerOpts) {

set.add(opt.getVoter());

for (Question question1 : questions) {

for (QuestionOpt questionOpt : question1.getOptions()) {

int num = 0;

for (AnswerOpt opt : answerOpts) {

if(questionOpt.getId() == opt.getOptId()){

num++;

questionOpt.setNum(num);

modelMap.addAttribute(“survey”,survey);

modelMap.addAttribute(“total”,set.size());

return “survey/query_detail”;

public String object2String(Object object){

if(object !=null){

return object+“”;

}else{

return null;

public Integer object2Integer(Object object){

if(object !=null){

return Integer.parseInt(object+“”);

}else{

return null;

后台管理员管理控制层:

@Controller

@RequestMapping(“/admin”)

public class AdminController {

@Autowired

private AdminService adminService;

@GetMapping(“/create”)

public String v_create(){

return “admin/add”;

@PostMapping(“/create”)

@ResponseBody

public Map<String,Object> create(@RequestBody Admin admin){

admin.setPassword(MD5Utils.getMD5(admin.getPassword()));

int result = adminService.create(admin);

if(result<=0){

//失败的情况下

return MapControl.getInstance().error().getMap();

return MapControl.getInstance().success().getMap();

@PostMapping(“/delete”)

@ResponseBody

public Map<String,Object> delete(String ids){

int result = adminService.deleteBatch(ids);

if(result<=0){

//失败的情况下

return MapControl.getInstance().error().getMap();

return MapControl.getInstance().success().getMap();

@PostMapping(“/update”)

@ResponseBody

public Map<String, Object> update(@RequestBody Admin admin){

int result = adminService.update(admin);

if(result<=0){

//失败的情况下

return MapControl.getInstance().error().getMap();

return MapControl.getInstance().success().getMap();

@GetMapping(“/list”)

public String list(){

return “admin/list”;

@PostMapping(“/query”)

@ResponseBody

public Map<String,Object> query(@RequestBody Admin admin, ModelMap modelMap){

System.out.println(admin.getPage());

System.out.println(admin.getLimit());

System.out.println(admin.getAccount());

List list = adminService.query(admin);

Integer count = adminService.count(admin);

return MapControl.getInstance().page(list,count).getMap();

@GetMapping(“/detail”)

public String detail(Integer id,ModelMap modelMap){

Admin admin = adminService.detail(id);

modelMap.addAttribute(“admin”,admin);

return “admin/update”;


基于javaweb的问卷调查系统(java+ssm+layui+jsp+mysql)相关推荐

  1. 基于javaweb的养老院管理系统(java+ssm+bootstrap+jsp+mysql)

    基于javaweb的养老院管理系统(java+ssm+bootstrap+jsp+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/mye ...

  2. 基于javaweb的汽车俱乐部管理系统(java+ssm+html+jsp+mysql)

    基于javaweb的汽车俱乐部管理系统(java+ssm+html+jsp+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/myecli ...

  3. 基于javaweb的房屋租赁管理系统(java+ssm+layui+mysql+jsp)

    基于javaweb的房屋租赁管理系统(java+ssm+layui+mysql+jsp) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/myecli ...

  4. 基于javaweb的酒店管理系统(java+ssm+layui+mysql)

    基于javaweb的酒店管理系统(java+ssm+layui+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/myeclipse/st ...

  5. 基于javaweb的房屋租赁系统(java+ssm+jsp+mysql)

    基于javaweb的房屋租赁系统(java+ssm+jsp+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/myeclipse/sts等 ...

  6. 基于javaweb的实现进销存系统(java+ssm+bootstrap+jsp+mysql)

    基于javaweb的实现进销存系统(java+ssm+bootstrap+jsp+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/mye ...

  7. 基于javaweb+SSM的实现进销存系统(java+SSM+BootStrap+jsp+mysql)

    项目介绍 进销存库存管理系统源码,采用了ssm框架,功能结构非常简单明了,界面也比较清爽大气,非常适合学生和Java新手拿来学习使用. 本项目主要分为管理员.销售.采购员三种角色: 管理员主要功能包括 ...

  8. 基于javaweb+ssm的农资采购销售系统(java+SSM+Easyui+maven+Mysql)

    基于javaweb+ssm的农资采购销售系统(java+SSM+Easyui+maven+Mysql) 项目描述: 一个完整的农资采购销售系统,系统分为前台会员注册登陆,农资信息浏览,农资详情信息查看 ...

  9. 基于javaweb的酒店管理系统(java+ssm+jsp+mysql)

    基于javaweb的酒店管理系统(java+ssm+jsp+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/myeclipse/sts等 ...

最新文章

  1. 设置cookie存活时间_Django之cookie、session、token
  2. 能跳过节假日的闹钟_非人哉:叫九月起床有多难?闹钟坏了许多个,哮天去叫被打了一顿...
  3. 【Sass】全面的 Sass 教程及学习笔记
  4. python 对象创建_从Python中的基类对象创建对象
  5. 为什么不应该重写 service 方法?
  6. 云炬Android开发笔记 2-3Android Studio如何导入Github上的项目
  7. docker-compose.yaml的一些坑(趁我还记得赶快记下来)
  8. java extensions JAR files
  9. SAP GUI security setting on local file access
  10. python 读取地震道头数据_【Python】OGR库(1):读取矢量数据
  11. Java Servlet response
  12. 开源Math.NET基础数学类库使用(03)C#解析Matlab的mat格式
  13. dubbo yml配置_Dubbo常见配置说明
  14. 当调用wcf, 小心返回值包含enum越界的错误。
  15. 百度搜索时,使用‘-csdn’屏蔽掉CSDN网站的博客和内容
  16. oracle服务商前几名,oracle厂商服务有哪几种
  17. golang ——An existing connection was forcibly closed by the remote host.
  18. 权威发布:新一代人工智能发展白皮书(2017)
  19. anaconda python更换清华源
  20. 思科配置系统日志服务器配置,思科交换机路由器配置日志服务器脚本

热门文章

  1. Zw函数与Nt函数的分别与联系
  2. fx系列微型可编程控制器 通信_三菱Q系列和FX系列的PLC有什么区别?
  3. busyBox date 在Motorola E680I 中的格式化输出
  4. 电信科学技术第五研究所怎么样_刘有成先生百年诞辰纪念会暨兰州大学功能有机分子化学国家重点实验室第七届学术委员会第五次会议在兰州大学召开 - 实验室动态 - 实验室动态...
  5. 【LeetCode】【OO Design】 Elevator
  6. 特劳特举办定位理论50周年全球盛典
  7. Python QT5设计UI界面教程
  8. tomcar与jdk
  9. 【阅读笔记】多任务学习之PLE(含代码实现)
  10. Music Theory for Songwriters: Rhythm 歌曲作者的音乐理论:节奏 Lynda课程中文字幕