作者主页:源码空间站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.
- */
- public void destroy() {
- super.destroy(); // Just puts "destroy" string in log
- // Put your code here
- }
-
- /**
- * The doGet method of the servlet.
- *
- * 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.
- *
- * 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.
- *
- * @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
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
select(String sql) { - int END = Integer.MAX_VALUE;
- int START = END - 100;
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- List
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
的形式返回查询的记录,记录条数,和从第几条开始,由参数决定,主要用于翻页 pageno 页码 - * rowsize 每页的条数
- */
- public List select(String sql, int pageno, int rowsize) {
- List
list = new ArrayList(); - List
mlist = new ArrayList(); - 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("\n");
- 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("");
- } else {
- chain.doFilter(request, response);
- }
- } else {
- chain.doFilter(request, response);
- }
-
- }
-
- public void init(FilterConfig arg0) throws ServletException {
- // TODO Auto-generated method stub
-
- }
-
- }
如果也想学习本系统,下面领取。关注并回复:076jsp