基于javaweb+mysql的jsp+servlet家政服务系统(java+jsp+jquery+servlet+mysql)

基于javaweb+mysql的jsp+servlet家政服务系统(java+jsp+jquery+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的JSP+Servlet家政服务系统(java+jsp+jquery+servlet+mysql)

项目介绍

本项目分为前后台,有普通用户与管理员两种角色,普通用户登录前台,管理员登录后台;

用户角色包含以下功能: 查看首页,客户注册,查看服务项目,查看服务项目详情,查看服务人员,查看家政新闻,在线留言等功能。

管理员角色包含以下功能: 管理员登录,管理员管理,客户信息管理,修改密码,员工信息管理,服务类别管理,服务项目管理,预约信息查询,留言管理,家政新闻管理,系统管理,友情链接添加,友情链接查询,系统公告设置等功能。

环境需要

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项目:否;

技术栈

JSP+CSS+JavaScript+jquery+Servlet+mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中dao/CommDAO.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/jsp_jzfw_site 登录
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100*1024*1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if(fileItem.getName()!=null && fileItem.getSize()!=0)
					{
						if(fileItem.getName()!=null && fileItem.getSize()!=0){
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(request.getRealPath("/upfile/")+"/" + filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						}else{
						}
					}
				}

				go("/js/uploadimg4.jsp?filename="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if(ac.equals("uploadimg5"))
		{
			try {
				String filename="";
				request.setCharacterEncoding("UTF-8");
				RequestContext  requestContext = new ServletRequestContext(request);
				if(FileUpload.isMultipartContent(requestContext)){

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
	{
	     
		PageManager pageManager = PageManager.getPage(url, pagesize, request);
		  pageManager.doList(sql);
		  PageManager bean = (PageManager) request.getAttribute("page");
		 
		  ArrayList<HashMap> nlist = (ArrayList) bean.getCollection();
		  return nlist;
	}

 
}

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
    public static String getDay(String date, int day) {
        String b = date.substring(0, 10);
        String c = b.substring(0, 4);
        String d = b.substring(5, 7);
        String f = b.substring(8, 10);
        String aa = c + "/" + d + "/" + f;
        String a = "";
        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
        GregorianCalendar grc = new GregorianCalendar();
        grc.setTime(new Date(aa));
        grc.add(GregorianCalendar.DAY_OF_MONTH, day);
        String resu = dateFormat.format(grc.getTime());
        String t[] = resu.split("-");
        String sesuu = "";
        for (int i = 0; i < t.length; i++) {
            if (t[i].length() == 1) {
                t[i] = "0" + t[i];
            }
            sesuu += t[i] + "-";
        }

        return sesuu.substring(0, 10);
    }

    /**
     * 计算两个时期之间的天数
     */
    public static int dayToday(String DATE1, String DATE2) {
        int i = 0;
        if (DATE1.indexOf(" ") > -1)
            DATE1 = DATE1.substring(0, DATE1.indexOf(" "));
        if (DATE2.indexOf(" ") > -1)
            DATE2 = DATE2.substring(0, DATE2.indexOf(" "));

        String[] d1 = DATE1.split("-");
        if (d1[1].length() == 1) {
            DATE1 = d1[0] + "-0" + d1[1];
        } else {
            DATE1 = d1[0] + "-" + d1[1];
        }

        if (d1[2].length() == 1) {
            DATE1 = DATE1 + "-0" + d1[2];
        } else {
					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100*1024*1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if(fileItem.getName()!=null && fileItem.getSize()!=0)
					{
						if(fileItem.getName()!=null && fileItem.getSize()!=0){
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(request.getRealPath("/upfile/")+"/" + filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						}else{
						}
					}
				}

				go("/js/uploaddoc2.jsp?docname="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if(ac.equals("uploaddoc3"))
		{
			try {
				String filename="";
				request.setCharacterEncoding("UTF-8");
				RequestContext  requestContext = new ServletRequestContext(request);
				if(FileUpload.isMultipartContent(requestContext)){

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100*1024*1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if(fileItem.getName()!=null && fileItem.getSize()!=0)
    }

    public static String getradio(String name, String tablename, String zdname, String where) {
        String radio = "";
        int dxii = 0;
        for (HashMap permap : new CommDAO().select("select * from " + tablename + " where  " + where + " order by id desc")) {
            String check = "";
            if (dxii == 0) check = "checked=checked";

            String optionstr = "";
            for (String str : zdname.split(";")) {
                String zdstr = str.split("~")[0];
                String zdnamestr = str.split("~")[1].equals("无名") ? "" : (str.split("~")[1] + ":");
                optionstr += zdnamestr + permap.get(zdstr) + " - ";
            }
            if (optionstr.length() > 0) optionstr = optionstr.substring(0, optionstr.length() - 3);

            radio += "<label><input type='radio' name='" + name + "' " + check + " value=\"" + optionstr + "\">" + optionstr + "</label>\n";
            dxii++;
        }
        return radio;
    }

    public static void writeExcel(String fileName, String prosstr, java.util.List<List> plist, HttpServletRequest request, HttpServletResponse response) {
        WritableWorkbook wwb = null;
        String cols = "";
        for (String str : prosstr.split("@")) {
            cols += str.split("-")[0] + ",";
        }
        cols = cols.substring(0, cols.length() - 1);
        String where = request.getAttribute("where") == null ? "" : request.getAttribute("where").toString();
        List<List> mlist = new CommDAO().selectforlist("select " + cols + " from " + fileName + " " + where + "  order by id desc");

        fileName = request.getRealPath("/") + "/upfile/" + Info.generalFileName("a.xls");
        String[] pros = prosstr.split("@");
        try {
            //首先要使用Workbook类的工厂方法创建一个可写入的工作薄(Workbook)对象
            wwb = Workbook.createWorkbook(new File(fileName));
        } catch (IOException e) {
            e.printStackTrace();

public class Info {

    //public static String popheight = "alliframe.height=document.body.clientHeight+";
    public static String popheight = "alliframe.style.height=document.body.scrollHeight+";

    public static HashMap getUser(HttpServletRequest request) {
        HashMap map = (HashMap) (request.getSession().getAttribute("username") == null ? request.getSession().getAttribute("user") : request.getSession().getAttribute("username"));
        return map;
    }

    public static int getBetweenDayNumber(String dateA, String dateB) {
        long dayNumber = 0;
        //1小时=60分钟=3600秒=3600000
        long mins = 60L * 1000L;
        //long day= 24L * 60L * 60L * 1000L;计算天数之差
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        try {
            java.util.Date d1 = df.parse(dateA);
            java.util.Date d2 = df.parse(dateB);
            dayNumber = (d2.getTime() - d1.getTime()) / mins;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (int) dayNumber;
    }
	 * @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
					 
				}
		      }
		 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);
					    }
		// "[" + (i + 1) + "]").append("</a>&nbsp;");
		// }

		// }
		buf.append("<select οnchange=\"javascript:window.location='").append(
				this.path).append("&currentPage='+").append(
				"this.options[this.selectedIndex].value").append(parameter)
				.append("\">");
		for (int i = 0; i < this.pageNumber; i++) {
			if (this.currentPage == i + 1)
				buf.append("<option value=" + (i + 1)
						+ " selected=\"selected\">" + (i + 1) + "</option>");
			else
				buf.append("<option value=" + (i + 1) + ">" + (i + 1)
						+ "</option>");

		}
		buf.append("</select>");
		this.info = buf.toString();
		
	}

	public Collection getCollection() {
		return collection;
	}

	public long getCount() {
		return count;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public long getPageNumber() {
		return pageNumber;
	}

	public int getPageSize() {
		return pageSize;
	}

	public String getInfo() {
		return info;
	}
	
	public static ArrayList<HashMap> getPages(String url,int pagesize,String sql,HttpServletRequest request )
	 * @param 当前HttpServletRequest对象
	 * @param 数据库操作对象
	 */
	public static PageManager getPage(String path, int pageSize,
			HttpServletRequest request) {
		return new PageManager(path, pageSize, request);

	}

	/**
	 * 
	 * 
	 * @param hql语句
	 * 
	 */
	public void doList(String hql) {
        
		this.count = this.dao.select(hql).size();
		if (this.count != 0) {
			this.pageNumber = count % this.pageSize == 0 ? this.count
					/ this.pageSize : this.count / this.pageSize + 1;
			if (this.currentPage > this.pageNumber)
				this.currentPage = (int) this.pageNumber;

		}
		this.request.getSession().setAttribute("currentPage",
				String.valueOf(this.currentPage));
		this.collection = this.dao.select(hql,
				this.currentPage , this.pageSize);

		this.refreshUrl();
	}

	/**
	 * 
	 * @param 查询条件集合
	 *            如没有条件只是列表就不使用这个方法
	 */
	public void addParameter(List parameter) {

		StringBuffer para = new StringBuffer("");
		if (parameter != null && parameter.size() != 0) {
			Iterator iterator = parameter.iterator();
			while (iterator.hasNext()) {
				para.append("&").append(iterator.next().toString());
			}
		}
		this.parameter = para.toString();

	}

        int i = 0;
        if (DATE1.indexOf(" ") > -1)
            DATE1 = DATE1.substring(0, DATE1.indexOf(" "));
        if (DATE2.indexOf(" ") > -1)
            DATE2 = DATE2.substring(0, DATE2.indexOf(" "));

        String[] d1 = DATE1.split("-");
        if (d1[1].length() == 1) {
            DATE1 = d1[0] + "-0" + d1[1];
        } else {
            DATE1 = d1[0] + "-" + d1[1];
        }

        if (d1[2].length() == 1) {
            DATE1 = DATE1 + "-0" + d1[2];
        } else {
            DATE1 = DATE1 + "-" + d1[2];
        }

        String[] d2 = DATE2.split("-");
        if (d2[1].length() == 1) {
            DATE2 = d2[0] + "-0" + d2[1];
        } else {
            DATE2 = d2[0] + "-" + d2[1];
        }

        if (d2[2].length() == 1) {
            DATE2 = DATE2 + "-0" + d2[2];
        } else {
            DATE2 = DATE2 + "-" + d2[2];
        }

        for (int j = 0; j < 10000; j++) {
            i = j;
            String gday = Info.getDay(DATE1, j);
            if (gday.equals(DATE2)) {
                break;
            }
        }
        return i;
    }

    /**
     * 比较时间大小
     */
    public static String compare_datezq(String DATE1, String DATE2) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
						}
					}
				}

				go("/js/uploadimg2.jsp?filename="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if(ac.equals("uploadimg3"))
		{
			try {
				String filename="";
				request.setCharacterEncoding("UTF-8");
				RequestContext  requestContext = new ServletRequestContext(request);
				if(FileUpload.isMultipartContent(requestContext)){

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100*1024*1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if(fileItem.getName()!=null && fileItem.getSize()!=0)
					{
						if(fileItem.getName()!=null && fileItem.getSize()!=0){
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(request.getRealPath("/upfile/")+"/" + filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						}else{
						}

            } catch (SQLException e) {
                e.printStackTrace();
            }
            String str = "";
            if (!reflush)
                str += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n";
            str += "<script language=javascript>\n";
            if (alert) {
                str += "alert('操作成功');\n";
            }
            if (tzurl.equals("")) {
                if (reflush) {
                    str += "parent.location=parent.location;\n";
                } else {
                    str += "window.location=String(window.location).replace(new RegExp('f=f', 'g'), '');";
                }
            } else {
                str += "location.href='" + tzurl + "';\n";
            }

            str += "</script>";

            PrintWriter wrt = null;
            try {
                wrt = response.getWriter();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            wrt.write(str);
        }

        return "";
    }

    public void delete(HttpServletRequest request, String tablename) {

        int i = 0;
        try {
            String did = request.getParameter("did");
            if (did == null) did = request.getParameter("scid");
            if (did != null) {
                if (did.length() > 0) {
                    Statement st = conn.createStatement();
                    System.out.println("delete from " + tablename + " where id=" + did);
                    st.execute("delete from " + tablename + " where id=" + did);
                    st.close();
                }
            }

        } catch (SQLException e) {
            // TODO Auto-generated catch block
                        String a = it.next().toString();
                        label1.setString(a);
                        ws.addCell(label1);
                        jj++;
                    }

                    i++;
                } catch (RowsExceededException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (WriteException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }

            try {
                //从内存中写入文件中
                wwb.write();
                //关闭资源,释放内存
                wwb.close();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        try {
            response.sendRedirect("upload?filename=" + fileName.substring(fileName.lastIndexOf("/") + 1));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getcheckbox(String name, String tablename, String zdname, String where) {
        String checkbox = "";
        for (HashMap permap : new CommDAO().select("select * from " + tablename + " where " + where + " order by id desc")) {

            String optionstr = "";
            for (String str : zdname.split(";")) {
                String zdstr = str.split("~")[0];
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if(fileItem.getName()!=null && fileItem.getSize()!=0)
					{
						if(fileItem.getName()!=null && fileItem.getSize()!=0){
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(request.getRealPath("/upfile/")+"/" + filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						}else{
						}
					}

					if(filename.indexOf(".xls")>-1)
					{
						Workbook workbook;
						try {
							workbook = Workbook.getWorkbook(new File(request.getRealPath("/upfile/")+"/"+filename));
							//通过Workbook的getSheet方法选择第一个工作簿(从0开始)
							Sheet sheet = workbook.getSheet(0);
							//通过Sheet方法的getCell方法选择位置为C2的单元格(两个参数都从0开始)
							//int empty = 0;
							for(int i=1;i<1000;i++)
							{
								Cell cell = null;
								try{
									String isql = "insert into "+tablename+"(";

									for(String str:whzdstr.split("-"))
									{
										isql+=str+",";
									}
									isql = isql.substring(0,isql.length()-1);
									isql+=")values(";

									int j=0;
									int empty = 1;
									for(String str:whzdstr.split("-"))
									{
										cell = sheet.getCell(j,i);
										isql+="'"+cell.getContents()+"',";
										String content = cell.getContents()==null?"":cell.getContents();
										if(!"".equals(content.trim()))
            HashMap typemap = new HashMap();
            ArrayList<String> collist = new ArrayList();
            String sql = "update " + tablename + " set ";
            Connection conn = this.getConn();
            try {
                Statement st = conn.createStatement();
                ResultSet rs = st.executeQuery("select * from " + tablename);
                ResultSetMetaData rsmd = rs.getMetaData();
                int i = rsmd.getColumnCount();
                System.out.println(i);
                for (int j = 1; j <= i; j++) {
                    if (rsmd.getColumnName(j).equals("id")) continue;
                    if (rsmd.getColumnName(j).equals("ID")) continue;
                    if (rsmd.getColumnName(j).equals("Id")) continue;
                    if (rsmd.getColumnName(j).equals("iD")) continue;
                    typemap.put(rsmd.getColumnName(j) + "---", rsmd.getColumnTypeName(j));
                    collist.add(rsmd.getColumnName(j));
                    if (names.indexOf("," + rsmd.getColumnName(j) + ",") > -1) {

                        String[] values = request.getParameterValues(rsmd.getColumnName(j));
                        String value = "";
                        for (String vstr : values) {
                            if (vstr == null) vstr = "";
                            if (vstr.equals("null")) vstr = "";
                            if (vstr.trim().equals("")) continue;

                            if (request.getParameter(vstr) != null && !"".equals(request.getParameter(vstr)) && request.getParameter("dk-" + rsmd.getColumnName(j) + "-value") != null) {
                                String dkv = request.getParameter(vstr);
                                String dknamevalue = request.getParameter("dk-" + rsmd.getColumnName(j) + "-value");
                                vstr += " - " + dknamevalue + ":" + dkv;
                                System.out.println(vstr);
                            }
                            //if(vstr.length()<)
                            value += vstr + " ~ ";
                        }
                        if (value == null) value = "";
                        if (value.equals("null")) value = "";
                        if (value.length() > 0) value = value.substring(0, value.length() - 3);

                        if (rsmd.getColumnTypeName(j).equals("int")) {
                            sql += rsmd.getColumnName(j) + "=" + value + ",";
                        } else {
                            sql += rsmd.getColumnName(j) + "='" + value + "',";
                        }
                    } else {
                        if (extmap.get(rsmd.getColumnName(j)) != null) {
				request.setCharacterEncoding("UTF-8");
				RequestContext  requestContext = new ServletRequestContext(request);
				if(FileUpload.isMultipartContent(requestContext)){

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100*1024*1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if(fileItem.getName()!=null && fileItem.getSize()!=0)
					{
						if(fileItem.getName()!=null && fileItem.getSize()!=0){
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(request.getRealPath("/upfile/")+"/" + filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						}else{
						}
					}
				}

				go("/js/uploadimg4.jsp?filename="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if(ac.equals("uploadimg5"))
		{
			try {
				String filename="";
				request.setCharacterEncoding("UTF-8");
				RequestContext  requestContext = new ServletRequestContext(request);
				if(FileUpload.isMultipartContent(requestContext)){

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100*1024*1024);
	// 分页段
	public static final int segment = 10;

	// 当前页数
	protected int currentPage;

	// 一页长度
	protected int pageSize;

	// 总页数
	protected long pageNumber;

	// 总记录数
	protected long count;

	// 数据
	protected Collection collection;

	// 数据查询对象
	protected CommDAO dao = new CommDAO();

	// 表现层代码
	protected String info;

	// 请求路径
	protected String path;

	// 服务器请求对象
	protected HttpServletRequest request;

	/*
	 * 仅仅只是加到路径中去
	 */
	protected String parameter = "";

	/**
	 * 
	 * @param 下一页的分页链接
	 * @param 一页最大记录数
	 * @param 当前HttpServletRequest对象
	 * @param 数据库操作对象
	 */
	protected PageManager(String path, int pageSize, HttpServletRequest request) {
		// 任意一个dao都行
		this.currentPage = 1;
		this.pageNumber = 1;
                    str += "window.location=String(window.location).replace(new RegExp('f=f', 'g'), '');";
                }
            } else {
                str += "location.href='" + tzurl + "';\n";
            }

            str += "</script>\n";

            PrintWriter wrt = null;
            try {
                //request.get
                wrt = response.getWriter();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            wrt.write(str);
        }
        return "";
    }

    public Connection getConn() {
        try {
            if (conn == null || conn.isClosed()) {

                Class.forName("com.mysql.jdbc.Driver");
                conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/project?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false&allowPublicKeyRetrieval=true&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull",
                        "root", "123456");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    public int getInt(String sql) {
        int i = 0;
        try {
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery(sql);
            if (rs.next()) {
                i = rs.getInt(1);
            }
            st.close();
        } catch (SQLException e) {

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值