Java项目:SSH校园失物招领平台系统

114 篇文章 4 订阅
111 篇文章 0 订阅

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

管理员角色包含以下功能:
管理员登录,用户管理,失物信息管理,招领信息管理,区域信息管理,类型信息管理,公告信息管理,帮助信息管理等功能。

用户角色包含以下功能:
查看失物招领信息,查看寻物启事,查看招领启事,查看帮助中心,个人中心管理,发布失物信息,发表查看评论,修改资料等功能。

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

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+hibernate+struts 2

2. 前端:HTML+CSS+JavaScript+jsp

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

4. 运行项目,输入localhost:8080/ 登录

运行截图

管理端页面

相关代码 

管理员控制器

@WebServlet("/guanliyuanServlet")
public class GuanliyuanServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GuanliyuanServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		 response.setCharacterEncoding("GB2312");
		 String methodName = request.getParameter("method");
			
			try {
				Method method = getClass().getDeclaredMethod(methodName, HttpServletRequest.class, HttpServletResponse.class);
				method.setAccessible(true);
				method.invoke(this, request, response);
			} catch (Exception e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
		}
	
	/*用户登录*/
	protected void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("GB2312"); 
        String zhanghao = request.getParameter("zhanghao");  
        String mima = request.getParameter("mima");
        GuanliyuanDao guanliyuanDao = new GuanliyuanDao();
        String psw =guanliyuanDao.getPassword(zhanghao);
        if(psw ==null){  
            request.getRequestDispatcher("/login.jsp").forward(request, response);  
        }  
        if(psw!=null&&!psw.equals(mima)){ 
            request.getRequestDispatcher("/login.jsp").forward(request, response);  
        }  
        if(psw.equals(mima)){  
            request.getRequestDispatcher("/admin.jsp").forward(request, response);  
            //response.setHeader("Refresh","1;url=welcome.jsp");  
        }
        
	}
	
	
	/*查找用户消息*/
	protected void finf_UserXiaoxi(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("GB2312"); 
        String id1 = request.getParameter("id");  
        int user_id = Integer.getInteger(id1);
        XiaoxiDao xiaoxiDao = new XiaoxiDao();
        Xiaoxi xiaoxi=xiaoxiDao.findByUser(user_id);
            request.setAttribute("xiaoxi", xiaoxi); 
            request.getRequestDispatcher("/edit-employee.jsp").forward(request, response);  
            //response.setHeader("Refresh","1;url=welcome.jsp");  
	}
}

消息管理控制器

@WebServlet("/xiaoxiServlet")
@MultipartConfig
public class XiaoxiServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public XiaoxiServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("GB2312");
		String methodName = request.getParameter("method");

		try {
			Method method = getClass().getDeclaredMethod(methodName, HttpServletRequest.class,
					HttpServletResponse.class);
			method.setAccessible(true);
			method.invoke(this, request, response);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

	
	/*寻物*/
	protected void add_Searchxiaoxi(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException, SQLException {		
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8"); 
		response.setContentType("text/html;charset=UTF-8");
		String zhuti = request.getParameter("zhuti");
		String neirong = request.getParameter("neirong");
		String wupin = request.getParameter("wupin");
        String lianxiren = request.getParameter("lianxiren");
        String tel = request.getParameter("tel");


//        System.out.println(zhuti+" "+neirong+" "+wupin+" "+lianxiren+" "+tel);
        
        Part part = request.getPart("pic");
		String fileName = photoDao.getPhotoNewName();
		String savePath = request.getSession().getServletContext().getRealPath("/imgs");
//		String savePath = "D:\\eclipse\\SearchAndFindPlatform(源码)\\WebContent\\imgs";
		System.out.println("保存路径:"+savePath);
		File f = new File(savePath+"/");
		if(!f.exists()) {
			f.mkdirs();
		}
		part.write(savePath+"/"+fileName);
		
		
        Date d = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String dateNow = sdf.format(d);
		
//		处理敏感词问题
		String t = request.getSession().getServletContext().getRealPath("sensitiveWords.txt");
//		String t = getServletContext.getRealPath("/sensitiveWords.txt");  
		SensitiveWordFilter filter = new SensitiveWordFilter(t);
		System.out.println("敏感词的数量:" + filter.sensitiveWordMap.size());
		Set<String> set = filter.getSensitiveWord(neirong, 1);
		System.out.println("语句中包含敏感词的个数为:" + set.size() + "。包含:" + set);
		System.out.println("替换关敏感词");
		String newNeirong = filter.replaceSensitiveWord(neirong,2,"*");
		System.out.println(newNeirong);
		

		
		Xiaoxi xiaoxi = new Xiaoxi();
		xiaoxi.setZhuti(zhuti);
		xiaoxi.setNeirong(newNeirong);
		xiaoxi.setShijian(dateNow);
		xiaoxi.setWupin(wupin);
		xiaoxi.setLianxiren(lianxiren);
		xiaoxi.setTel(tel);
		xiaoxi.setImagesName(fileName);
//		System.out.println(zhuti+" "+neirong+" "+wupin+" "+lianxiren+" "+tel+" "+"\n"+fileName);
		XiaoxiDao xiaoxiDao = new XiaoxiDao();
		int b=xiaoxiDao.insertsearch(xiaoxi);
        if(b==1) {
            request.getRequestDispatcher("/index.jsp").forward(request, response);
        }
		
	}
	
	/*招领*/
	protected void add_Findxiaoxi(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException, SQLException {		
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8"); 
		String zhuti = request.getParameter("zhuti");
		String neirong = request.getParameter("neirong");
		String wupin = request.getParameter("wupin");
        String lianxiren = request.getParameter("lianxiren");
        String tel = request.getParameter("tel");

        String imagePath =request.getParameter("");
        
        Part part = request.getPart("pic");
        System.out.println("______________>"+part);
		String fileName = photoDao.getPhotoNewName();
		String savePath = request.getSession().getServletContext().getRealPath("/imgs");
//		String savePath = "D:\\eclipse\\SearchAndFindPlatform(源码)\\WebContent\\imgs";
		System.out.println("保存路径:"+savePath);
		File f = new File(savePath+"/");
		if(!f.exists()) {
			f.mkdirs();
		}
		part.write(savePath+"/"+fileName);
        
//		处理敏感词问题
//		String t = getServletContext().getRealPath("/sensitiveWords.txt");

		String t = request.getSession().getServletContext().getRealPath("sensitiveWords.txt");
		SensitiveWordFilter filter = new SensitiveWordFilter(t);
		System.out.println("敏感词的数量:" + filter.sensitiveWordMap.size());
		Set<String> set = filter.getSensitiveWord(neirong, 1);
		System.out.println("语句中包含敏感词的个数为:" + set.size() + "。包含:" + set);
		System.out.println("替换关敏感词");
		String newNeirong = filter.replaceSensitiveWord(neirong,2,"*");
		System.out.println(newNeirong);
        
        Date d = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String dateNow = sdf.format(d);
		Xiaoxi xiaoxi = new Xiaoxi();
		xiaoxi.setZhuti(zhuti);
		xiaoxi.setNeirong(newNeirong);
//		xiaoxi.setNeirong(neirong);
		xiaoxi.setShijian(dateNow);
		xiaoxi.setWupin(wupin);
		xiaoxi.setLianxiren(lianxiren);
		xiaoxi.setTel(tel);
		xiaoxi.setImagesName(fileName);
		XiaoxiDao xiaoxiDao = new XiaoxiDao();
		int b=xiaoxiDao.insertfind(xiaoxi);
        if(b==1) {
            request.getRequestDispatcher("/index.jsp").forward(request, response);
        }
		
	}

	
	//模糊查询
	protected void findMohu_Xiaoxi(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("GB2312"); 
        String zhuti = request.getParameter("zhuti");  
        XiaoxiDao xiaoxiDao = new XiaoxiDao();
        ArrayList<Xiaoxi> xiaoxi =null;
        xiaoxi = xiaoxiDao.findmohuAll("%"+zhuti+"%");
        System.out.println("%"+zhuti+"%");
        if(xiaoxi==null){  
            request.setAttribute("msg", "没有该物品信息!");  
            request.getRequestDispatcher("/found.jsp").forward(request, response);  
        }  else {
        	request.setAttribute("zhuti", zhuti); 
            request.setAttribute("xiaoxi", xiaoxi); 
            request.getRequestDispatcher("/found.jsp").forward(request, response);  
            //response.setHeader("Refresh","1;url=welcome.jsp");  
        }
    }
	
//	删除寻物信息
	protected void deleteById_xiaoxi1(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("GB2312"); 
		XiaoxiDao xiaoxiDao = new XiaoxiDao();
		String id = request.getParameter("id");
		int idInt = Integer.parseInt(id);
		int b = xiaoxiDao.delete(idInt);
		if(b==1) {
			request.getRequestDispatcher("/search-manager.jsp").forward(request, response);
		}
	}
	
//	删除招领信息
	
	protected void deleteById_xiaoxi2(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("GB2312"); 
		XiaoxiDao xiaoxiDao = new XiaoxiDao();
		String id = request.getParameter("id");
		int idInt = Integer.parseInt(id);
		int b = xiaoxiDao.delete(idInt);
		if(b==1) {
			request.getRequestDispatcher("/find-manager.jsp").forward(request, response);
		}
	}
	
	

}

如果也想学习本系统,下面领取。关注并回复:043ssh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值