当前位置: 首页 > news >正文

Java项目:JSP高校新生报到迎新管理系统

作者主页:源码空间站2022

 简介: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版本;

技术栈

HTML+CSS+JavaScript+jsp+mysql

使用说明

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

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

运行截图

相关代码 

Upload

package control;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import util.Info;

public class Upload extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public Upload() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		StringBuffer   sb   =   new   StringBuffer(50);   
		 response.setContentType("application/x-msdownload;charset=utf-8");   
        try {
			response.setHeader("Content-Disposition",   new   String(sb.toString()   
			         .getBytes(),   "ISO8859-1"));
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		 String filename = request.getParameter("filename");
		  if (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0){
		     try {
				filename = new String(filename.getBytes("UTF-8"), "ISO8859-1");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		 }
		 else 
		      if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0){
		           try {
					filename = URLEncoder.encode(filename, "UTF-8");
				} catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		      }
		 response.setContentType("text/plain");
		 response.setHeader("Location",filename);
		 response.reset();
		 response.setHeader("Cache-Control", "max-age=0" );
		 response.setHeader("Content-Disposition", "attachment; filename=" + filename);
		   

		    try {
				       BufferedInputStream bis = null;
					   BufferedOutputStream bos = null;
					   OutputStream fos = null;
					  // File f = new File(request.getRealPath("/upfile/")+"/"+filename);
					   //System.out.println(f);
					   bis = new BufferedInputStream((InputStream)new FileInputStream(request.getRealPath("/upfile/")+"/"+filename));
					    fos = response.getOutputStream();
					    bos = new BufferedOutputStream(fos);

					    int bytesRead = 0;
					    byte[] buffer = new byte[5 * 1024];
					    while ((bytesRead = bis.read(buffer)) != -1) {
					     bos.write(buffer, 0, bytesRead);
					    }
					    bos.close();
					    bis.close();
					    fos.close();
				
		     } catch (Exception e) {
				e.printStackTrace();
			}finally{
			}
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

CommDAO

package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import util.SimpleDataSource;

public class CommDAO {

	public Connection getConn() {
		Connection conn = null;
		try {
			conn = SimpleDataSource.instance().getConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}

	public int getInt(String sql) {
		int i = 0;
		Connection conn = getConn();
		Statement st = null;
		try {
			st = conn.createStatement();
			ResultSet rs = st.executeQuery(sql);
			if (rs.next()) {
				i = rs.getInt(1);
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				SimpleDataSource.freeConnection(conn);
				if (null != st) {
					st.close();
				}

			} catch (Exception e) {

			}

		}
		return i;
	}

	public double getDouble(String sql) {
		double i = 0;
		Connection conn = getConn();
		Statement st = null;
		try {
			st = conn.createStatement();
			ResultSet rs = st.executeQuery(sql);
			if (rs.next()) {
				i = rs.getDouble(1);

			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				if (null != conn) {
					conn.close();
				}
				if (null != st) {
					st.close();
				}

			} catch (Exception e) {

			}

		}
		return i;
	}

	public void commOper(String sql) {
		Connection conn = getConn();
		Statement st = null;
		try {
			st = conn.createStatement();
			st.execute(sql);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				SimpleDataSource.freeConnection(conn);
				if (null != st) {
					st.close();
				}

			} catch (Exception e) {

			}

		}
	}

	public void commOperSqls(ArrayList<String> sql) {
		Connection conn = getConn();
		Statement st = null;
		try {
			conn.setAutoCommit(false);
			for (int i = 0; i < sql.size(); i++) {
				st = conn.createStatement();

				st.execute(sql.get(i));
				st.close();
			}
			conn.commit();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				conn.setAutoCommit(true);
				SimpleDataSource.freeConnection(conn);
				if (null != st) {
					st.close();
				}

			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

	public List<HashMap> select(String sql) {
		int END = Integer.MAX_VALUE;
		int START = END - 100;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		List<HashMap> list = new ArrayList();
		Connection conn = getConn();
		Statement st = null;
		try {
			st = conn.createStatement();
			ResultSet rs = st.executeQuery(sql);
			ResultSetMetaData rsmd = rs.getMetaData();

			while (rs.next()) {
				HashMap map = new HashMap();
				int i = rsmd.getColumnCount();
				for (int j = 1; j <= i; j++) {
					if (!rsmd.getColumnName(j).equals("ID")) {
						map.put(rsmd.getColumnName(j),
								rs.getString(j) == null ? "" : rs.getString(j));
					} else {

						map.put("id", rs.getString(j));
					}
				}
				list.add(map);
			}
			rs.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			System.out.println("--" + sql);
			e.printStackTrace();
		} finally {
			try {
				conn.setAutoCommit(true);
				SimpleDataSource.freeConnection(conn);
				if (null != st) {
					st.close();
				}

			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	/**
	 * 执行一条查询sql,以 List<hashmap> 的形式返回查询的记录,记录条数,和从第几条开始,由参数决定,主要用于翻页 pageno 页码
	 * rowsize 每页的条数
	 */
	public List select(String sql, int pageno, int rowsize) {
		List<HashMap> list = new ArrayList<HashMap>();
		List<HashMap> mlist = new ArrayList<HashMap>();
		try {
			list = this.select(sql);
			int min = (pageno - 1) * rowsize;
			int max = pageno * rowsize;

			for (int i = 0; i < list.size(); i++) {

				if (!(i < min || i > (max - 1))) {
					mlist.add(list.get(i));
				}
			}
		} catch (RuntimeException re) {
			re.printStackTrace();
			throw re;
		}

		return mlist;
	}

	// 该方法返回一个table 用于流动图片
	public String DynamicImage(String categoryid, int cut, int width, int height) {

		StringBuffer imgStr = new StringBuffer();
		StringBuffer thePics1 = new StringBuffer();
		StringBuffer theLinks1 = new StringBuffer();
		StringBuffer theTexts1 = new StringBuffer();

		imgStr.append("<div id=picViwer1 align=center></div><SCRIPT src='/databasesys/js/dynamicImage.js' type=text/javascript></SCRIPT>\n<script language=JavaScript>\n");
		thePics1.append("var thePics1=\n'");
		theLinks1.append("var theLinks1='");
		theTexts1.append("var theTexts1='");

		List<HashMap> co = this
				.select("select * from  news where title!='系统简介计算机课程管理系统' and  title!='毕业设计栏目管理' order by id desc",
						1, 6);
		int j = 0;
		int i = co.size();
		for (HashMap b : co) {
			j++;
			String id = b.get("id").toString();
			String title = b.get("title").toString();

			String url = "/databasesys/upfile/" + b.get("picurl");

			String purl = "";

			if (j != i) {
				thePics1.append(url.replaceAll("\n", "") + "|");
				theLinks1.append(purl + "|");
				theTexts1.append(title + "|");
			}
			if (j == i) {
				thePics1.append(url.replaceAll("\n", ""));
				theLinks1.append("#");
				theTexts1.append(title);
			}

		}
		thePics1.append("';");

		theLinks1.append("';");
		theTexts1.append("';");
		imgStr.append(thePics1 + "\n");
		imgStr.append(theLinks1 + "\n");
		imgStr.append(theTexts1 + "\n");
		imgStr.append("\n setPic(thePics1,theLinks1,theTexts1," + width + ","
				+ height + ",'picViwer1');</script>");
		return imgStr.toString();
	}

	public static void main(String[] args) {
		System.out.println(new CommDAO());
	}
}

LoginFilter

package util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class LoginFilter implements Filter {

	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		// TODO Auto-generated method stub
		HttpServletRequest request = (HttpServletRequest) req;
		HttpServletResponse response = (HttpServletResponse) res;
		HttpSession session = request.getSession();
		// 如果session不为空,则可以浏览其他页面
		String url = request.getServletPath();
		//System.out.println(url);
		String path = request.getRequestURI();
		//这里判断目录,后缀名,当然也可以写在web.xml中,用url-pattern进行拦截映射
		if ((!request.getServletPath().equals("/admin/login.action"))
				&& (!request.getServletPath().equals("/admin/login.jsp"))
				&& (!request.getServletPath().equals("/admin/relogin.jsp"))
				&& (!request.getServletPath().equals("/admin/lib/font-awesome/css/font-awesome.css"))
				&& (!request.getServletPath().equals("/admin/lib/bootstrap/js/bootstrap.js"))
				&& (!request.getServletPath().equals("/admin/lib/jquery-1.7.2.min.js"))
				&& (!request.getServletPath().equals("/admin/stylesheets/theme.css"))
				&& (!request.getServletPath().equals("/admin/lib/bootstrap/css/bootstrap.css"))
				) {
			// 登陆页面无需过滤
			if(path.indexOf("/admin/login.jsp") > -1) {
				chain.doFilter(request, response);
				return;
			}
			
			

			if (session.getAttribute("admin") == null) {
				session.invalidate();
				response.setContentType("text/html;charset=gb2312");
				PrintWriter out = response.getWriter();
				out.println("<script language='javascript' type='text/javascript'>");
				out.println("alert('由于你长时间没有操作,导致Session失效!请你重新登录!');parent.location.href='" + request.getContextPath() + "/admin/login.jsp'");
				out.println("</script>");
			} else {
				chain.doFilter(request, response);
			}
		} else {
			chain.doFilter(request, response);
		}

	}

	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub

	}

}

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

 

相关文章:

  • Linux kprobe原理
  • 03、Spring中的静态代理JDK动态代理CGLB动态代理
  • echarts——实现3D地图+3D柱状图 效果——粗糙代码记录——技能提升
  • 从一道题到贪心入门
  • Redis缓存的雪崩、穿透、击穿
  • 腾讯云COS+PicGo+Typora十分钟搭建自己的图床
  • 第十四届蓝桥杯(Web应用开发)模拟赛1期-大学组
  • js逆向tips-某思录登录
  • 为了摸鱼,我开发了一个工具网站
  • OpenCV图像处理——(实战)答题卡识别试卷
  • 朋友电脑密码忘了,我当场拔了她的电源,结果。。。
  • SpringBoot: Controller层的优雅实现
  • LeetCode135. 分发糖果(贪心算法)
  • c语言:初识结构体
  • ASEMI肖特基二极管SBT40100VFCT规格,SBT40100VFCT封装
  • 谁能拒绝一个会动的皮卡丘挂件
  • docker 安装minio
  • 云原生系列 五【轻松入门容器基础操作】
  • Python - 异常处理
  • 经济师十大专业通过人数分析!选专业有谱了!