——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明







基于javaweb的SSM+Maven问卷调查系统(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等版本均可;
技术栈
- 后端:Spring Springmvc Mybatis 2. 前端:JSP+css+javascript+jQuery+layui
使用说明
- 使用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
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| for (QuestionOpt questionOpt : question1.getOptions()) { int num = 0; for (AnswerOpt opt : answerOpts) { if(questionOpt.getId().equals(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; } }
} package com.yanzhen.controller;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| @Controller public class IndexController {
@Value("classpath:init.json") private Resource resource;
@GetMapping("/index") public String index() { return "index"; }
@GetMapping("/info") public String info(){ return "info"; }
@GetMapping("/menu") @ResponseBody public void menu(HttpServletResponse response) { try { File file = resource.getFile(); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); String str; StringBuffer sb = new StringBuffer(); while ((str = bufferedReader.readLine()) !=null){ sb.append(str); } bufferedReader.close(); fileReader.close(); response.setContentType("application/json;charset=utf-8"); response.getWriter().print(sb.toString()); } catch (IOException e) { e.printStackTrace(); } }
} package com.yanzhen.utils;
public class SessionInterceptor implements HandlerInterceptor {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| 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<Question> questions = questionService.query(question); survey.setQuestions(questions);
AnswerOpt answerOpt = new AnswerOpt(); answerOpt.setSurveyId(id); List<AnswerOpt> answerOpts = surveyService.queryAnswerOpt(answerOpt); Set<String> set = new HashSet<String>(); 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().equals(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{
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| @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<Admin> 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){
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| @PostMapping("/query") @ResponseBody public Map<String,Object> query(@RequestBody Question question, ModelMap modelMap){ List<Question> list = questionService.query(question); Integer count = questionService.count(question); return MapControl.getInstance().page(list,count).getMap(); }
@GetMapping("/detail") public String detail(Integer id,ModelMap modelMap){ Question question = questionService.detail(id); modelMap.addAttribute("question",question); return "question/update"; }
@GetMapping("/question") public String question(Integer id,ModelMap modelMap){ Question question = questionService.detail(id); modelMap.addAttribute("question",question); return "question/question"; }
} package com.yanzhen.controller;
@Controller @RequestMapping("/admin") public class AdminController {
@Autowired private AdminService adminService;
@GetMapping("/create")
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| 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<Object> opts = (List<Object>) 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<Question> questions = questionService.query(question); survey.setQuestions(questions);
AnswerOpt answerOpt = new AnswerOpt();
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=211122542008200sj
https://javayms.pages.dev?id=211122542008200sj