基于SSM的“野生动物公益保护系统”的设计与实现(源码+数据库+文档)
-
开发语言:Java
-
数据库:MySQL
-
技术:SSM
-
工具:IDEA/Ecilpse、Navicat、Maven
系统展示
系统功能结构图
系统登录界面
动物管理模块实现界面
活动管理模块实现界面
首页模块界面
公益活动实现界面
摘要
本系统按照网站系统设计的基本流程,遵循系统开发生命周期法和结构化方法,基于Java语言设计并实现了野生动物公益保护系统。该系统基于浏览器/服务器模式,采用JSP技术,后台数据库系统选择MySQL数据库。系统分为前台和后台两部分,前台包括登录、注册、首页、个人中心、公益基金、公益活动等功能模块;后台包括用户管理、动物管理、基金管理、活动管理、留言管理等功能模块。
本文首先分析了课题的研究背景与研究现状,然后根据软件开发流程,对系统进行可行性分析和需求分析。通过对系统总体功能模块的设计提出了系统的功能模块图,并对数据库的结构进行设计。然后,根据设计的框架实现了系统的各个功能模块。最后,对设计的系统进行单元测试和性能测试。测试结果表明,本系统能够实现所需的功能,并且运行状况良好。
背景及意义
志愿服务是一项以自愿且不图报酬的方式参与社会生活,促进社会进步,推动人类发展的社会事业。从世界范围来看,志愿服务事业已经有了上百年的历史,至今在世界各国方兴未艾,已经成为一项推动社会进步,催生现代文明的世界性运动,得到了各国政府的普遍重视和人民的积极参与。志愿服务推动了中国现代化的进程改革开放30年以来,以服务社会、服务他人为目的的社会志愿服务由小变大、由弱变强,成为构建社会主义和谐社会的重要组成因素,体现出强大的生命力。社会组织的界定社会组织是指为了针对特定的目标,为完成特定的职能,具有明确规章制度的一个独立单位,是正式化的社会群体。社会组织分类方法很多,按其职责和功能,分为公益类、服务类、维权类、文体类和保健类五类社会组织。
随着计算机技术的飞速发展,利用计算机实现“野生动物公益保护”志愿活动事务的管理势在必行。利用计算机支持协会组织高效率完成活动管理的日常事务,是适应现代社会发展要求,推动志愿活动事务管理走向科学化、规范化的必要条件。
课题研究现状
目前用于web开发的主要技术有JSP、PHP等,现在web开发中基于B/S架构的程序设计语言已非常成熟,JSP是一种新的动态Web应用技术标准。JSPWeb页是由传统Web页的HTML文档加入Java程序片段和JSP标记构成的[10]。HTML代码用来描述信息的显示格式,而Java.程序段则负责描述处理逻辑,根据需要可以是数据库操作、Web页重新定向等。Web服务器在接到访问JSPWeb页的请求时,首先执行嵌入在其中的程序段,然后将执行结果重新嵌入HTML代码,一起发送给客户端。作为新一代的站点开发语言,JSP克服了ASP脚本级执行的不足,可以在Servlet的支持下开发出功能强大的Web应用。
部分源码
@Controller
public class AnimalController {
@Autowired
private AnimalService animalService;
@Autowired
private LoginService loginService;
// Ìí¼Ó¶¯Îï
@RequestMapping(value = "/insertAnimal.do")
public String insertCourse(@RequestParam("files") MultipartFile[] files,
HttpServletRequest request, HttpServletResponse response,
HttpSession session) throws IOException {
String animalname = request.getParameter("coursename");
String animaltype = request.getParameter("chapter");
String habitat = request.getParameter("teacher");
String num = request.getParameter("num");
String introduce = request.getParameter("courseintroduce");
String path = "F:/MyEclipseFiles/animal/WebRoot/images/addVideo/";
String src0 = "", src1 = "";
// ÅжÏfileÊý×é²»ÄÜΪ¿Õ²¢ÇÒ³¤¶È´óÓÚ0
if (files != null && files.length > 0) {
// Ñ»·»ñÈ¡fileÊý×éÖеÃÎļþ
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
// ±£´æÎļþ
if (!file.isEmpty()) {
try {
File filepath = new File(path);
if (!filepath.exists())
filepath.mkdirs();
// Îļþ±£´æÂ·¾¶
// ת´æÎļþ
file.transferTo(new File(path
+ file.getOriginalFilename()));
// ½«Ïà¶Ô·¾¶²åÈëÊý¾Ý¿â
if (i == 0)
src0 = "images/addVideo/"
+ file.getOriginalFilename();
else
src1 = "images/addVideo/"
+ file.getOriginalFilename();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
animalService.insertAnimal(animalname, animaltype, src0, src1, habitat,
Integer.parseInt(num), introduce);
response.setContentType("text/html;charset=utf-8");
response.getWriter().write("<script>alert('¶¯ÎïÐÅÏ¢ÉÏ´«³É¹¦£¡');</script>");
response.getWriter().flush();
return "views/admin/animaltable";
}
// ºǫ́¹ÜÀí¶¯Îï
@RequestMapping("/animalTable.do")
public ModelAndView courseTable() {
List<Animal> findPictureList = animalService.selectAllAnimal();
ModelAndView mv = new ModelAndView();
mv.addObject("findAnimalList", findPictureList);
mv.setViewName("views/admin/animalTable");
return mv;
}
// ºǫ́ij¸ö¶¯ÎïÁбí
@RequestMapping("/upAnimal.do")
public String upAnima(HttpServletRequest request,HttpSession session) {
String id=request.getParameter("id");
List<Animal> pictureList = animalService.selectOneAnimal(Integer.parseInt(id));
session.setAttribute("animal", pictureList);
return "views/admin/upAnimal";
}
// ºǫ́Ð޸͝Îï
@RequestMapping(value = "/upAnimalInfo.do")
public String upAnimalInfo(@RequestParam("files") MultipartFile[] files,
HttpServletRequest request, HttpServletResponse response,
HttpSession session) throws IOException {
String id=request.getParameter("id");
String animalname = request.getParameter("coursename");
String animaltype = request.getParameter("chapter");
String habitat = request.getParameter("teacher");
String num = request.getParameter("num");
String introduce = request.getParameter("courseintroduce");
String path = "F:/MyEclipseFiles/animal/WebRoot/images/addVideo/";
String src0 = "", src1 = "";
// ÅжÏfileÊý×é²»ÄÜΪ¿Õ²¢ÇÒ³¤¶È´óÓÚ0
if (files != null && files.length > 0) {
// Ñ»·»ñÈ¡fileÊý×éÖеÃÎļþ
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
// ±£´æÎļþ
if (!file.isEmpty()) {
try {
File filepath = new File(path);
if (!filepath.exists())
filepath.mkdirs();
// Îļþ±£´æÂ·¾¶
// ת´æÎļþ
file.transferTo(new File(path
+ file.getOriginalFilename()));
// ½«Ïà¶Ô·¾¶²åÈëÊý¾Ý¿â
if (i == 0)
src0 = "images/addVideo/"
+ file.getOriginalFilename();
else
src1 = "images/addVideo/"
+ file.getOriginalFilename();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
animalService.updateAnimal(Integer.parseInt(id), animalname, animaltype, src0, src1, habitat, Integer.parseInt(num), introduce);
response.setContentType("text/html;charset=utf-8");
response.getWriter().write("<script>alert('¶¯ÎïÐÅÏ¢Ð޸ijɹ¦£¡');</script>");
response.getWriter().flush();
return "views/admin/animaltable";
}
// ɾ³ý¶¯Îï
@RequestMapping(value = "/delAnimal.do")
@ResponseBody
public String delAnimal(@RequestParam int id) throws IOException {
animalService.deleteAnimal(id);
return "true";
}
// Ê×ҳչʾ¸÷ÖÖÀàÐ͵͝Îï
@RequestMapping("/index.do")
public ModelAndView selectPicBytype(HttpSession session) {
List<Animal> oneList = animalService.selectAnimalByName("ʳÈ⶯Îï");
List<Animal> twoList = animalService.selectAnimalByName("ʳ²Ý¶¯Îï");
List<Animal> thereList = animalService.selectAnimalByName("ÔÓʳ¶¯Îï");
ModelAndView mv = new ModelAndView();
mv.addObject("oneList", oneList);
mv.addObject("twoList", twoList);
mv.addObject("thereList", thereList);
mv.setViewName("views/login/index");
return mv;
}
// ij¸ö¶¯ÎïÁбí
@RequestMapping("/animalInfo.do")
public String animalInfo(HttpServletRequest request, HttpSession session) {
String animalid = request.getParameter("id");
List<Animal> pictureList = animalService.selectOneAnimal(Integer
.parseInt(animalid));
session.setAttribute("animalList", pictureList);
return "views/animal/animalInfo";
}
// ¼ìË÷¶¯Îï
@RequestMapping("/search.do")
@ResponseBody
public String search(@RequestParam String coursename, HttpSession session) {
List<Animal> searchList = animalService.selectAnimalByName(coursename);
if(searchList.size()>0)
session.setAttribute("searchList", searchList);
else{
session.removeAttribute("searchList");
String username=(String) session.getAttribute("username");
int userid=loginService.findUserid(username);
animalService.insertTixing(userid, coursename);
}
return "true";
}
}
结论
本文主要阐述了如何利用JSP的Struts和Hibernate框架开发一个性能优化、可扩展性强和安全可靠的野生动物公益保护系统。系统分为前台和后台两部分,前台包括登录、注册、首页、个人中心、公益基金、公益活动等功能模块;后台包括用户管理、动物管理、基金管理、活动管理、留言管理等功能模块。然后根据这些功能进行分析设计,对所用到Struts、JSP等技术进行简要的介绍,接着进行需求分析的描述。接着是概要设计和详细设计。描述这个系统的部分功能的实现方案及过程。
本设计所实现的是一个野生动物公益保护系统,系统按照总体设计、数据库设计、各个模块设计和代码分析,野生动物公益保护系统的基本功能已得到实现。由于时间及本人所学有限,该系统还有许多地方需要改进,并且还有许多自己未起到的功能,本人会在以后的学习过程中进一步加强和完善。