基于javaweb+mysql的jsp+servlet在线旅游旅行综合服务平台(java+mysql+jsp+servlet)

基于javaweb+mysql的jsp+servlet在线旅游旅行综合服务平台(java+mysql+jsp+servlet)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

前台用户+后台管理

基于javaweb+mysql的JSP+Servlet在线旅游旅行综合服务平台(java+mysql+jsp+servlet)

		if (this.currentPage == 1)
			buf.append("首页");
		else
			buf.append("<a href='").append(this.path).append("&currentPage=1")
					.append(parameter)
					.append("' class='ls'>").append("首页")
					.append("</a>");
		// #1157B7
		buf.append("&nbsp;&nbsp;&nbsp;&nbsp;");

		if (this.currentPage > 1) {
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(currentPage - 1).append(parameter).append(
							"' class='ls'>").append("上页")
					.append("</a>");
		} else {
			buf.append("上页");

		}
		buf.append("&nbsp;&nbsp;");

		int currentSegment = this.currentPage % segment == 0 ? this.currentPage
				/ segment : this.currentPage / segment + 1;

		/*for (int i = 1; i <= this.pageNumber; i++) {
			if (this.currentPage == i)
				buf.append("<font color='red'>").append(i).append("</font>");

			else
				buf.append("<a href='").append(this.path).append(
						"&currentPage=").append(i).append(parameter).append(
						"' class='ls'>[").append(i).append(
						"]</a>");
		}*/

		buf.append("&nbsp;&nbsp;");
		if (this.currentPage < this.pageNumber) {
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(currentPage + 1).append(parameter).append(
							"' class='ls'>").append("下页")
					.append("</a>");
		} else {

			buf.append("下页");

		}

		buf.append("&nbsp;&nbsp;&nbsp;&nbsp;");
		if (this.currentPage == this.pageNumber)
			buf.append("末页&nbsp;&nbsp;");
		else
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(this.pageNumber).append(parameter).append(
							"' class='ls'>").append("末页")
	          source=sub1+sub2;
	         }
	         //System.out.println(start+" "+end);
	        }
	        return source;
	   }
	    
	   
	    public static void delPic(String path,String img)
		{
			 if(img!=null)
			 {
				 if(!img.equals(""))
				 {
			  File file1=new File(path + "/" + img); 
		       if(file1.exists() ) {
		    	file1.deleteOnExit();
		     //    file1.delete();
		       }}}
		}
	    
	    
	     

		
		
}

		

			 
			 String optionstr = "'";
			 for(String str:zdname.split(";"))
			 {
				 if(str.indexOf("~")>-1){
				 String zdstr = str.split("~")[0];
				 String zdnamestr = str.split("~")[1].equals("无名")?"":(str.split("~")[1]+":");
				 optionstr+=zdnamestr+permap.get(zdstr)+" - ";
				 }else{ 
					 optionstr+=permap.get(str); 
				 }
			 }
			 if(optionstr.length()>0)optionstr=optionstr.substring(0,optionstr.length()-3);
			 optionstr+="',";
			 checkbox+= optionstr;
		 }
		 if(checkbox.length()>0)checkbox=checkbox.substring(0,checkbox.length()-1);
		 
		 return checkbox;
	 }
	 
	 
	 
	 
	 public static String getcheckboxDk(String name,String tablename,String zdname,String nstr,String where)
	 { 
		 String checkbox="";
		 int i=0;
		 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];
				 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);
			 String nbs = "";
			 if(i>0)nbs="&nbsp;";
			 checkbox+="<label>"+nbs+"<input type='checkbox' name='"+name+"' value=\""+optionstr+"\">"+optionstr+"</label>&nbsp;&nbsp;\n";
			 checkbox+="<label>&nbsp;- "+nstr+" &nbsp;<input type='text' size='5' name='"+optionstr+"' value=\"\"></label><br />\n";
			 i++;
		 }
		 checkbox+="<input type=hidden name='"+name+"' value='' /><input type=hidden name='dk-"+name+"-value' value='"+nstr+"' />";
		 return checkbox;
	 }
	 

	 public static String getFileUpInfo()
		{
			String jscode = "";
		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();
			   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/uploadimg3.jsp?filename="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			    }
		}
		
		if(ac.equals("uploadimg4"))
		{
			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);
				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{
			     }
			    }
			}
			
			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);

public class CommDAO {
    public static String dbname = "";
    public static String dbtype = "";

    public static Connection conn = null;

    public CommDAO() {
        conn = this.getConn();
    }

    //给字段做加减法
    public void jiajian(String tablename, String colname, String id, String num) {
        HashMap map = this.getmap(id, tablename);
        String value = map.get(colname).toString();
        if (value.equals("")) value = "0";
        int i = Integer.parseInt(value);
        int j = Integer.parseInt(num);
        commOper("update " + tablename + " set " + colname + " = " + (i + j) + " where id=" + id);
    }

    //	该方法返回一个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  style='background-color: #ffffff' align=center></div><SCRIPT src='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 xinwentongzhi where shouyetupian<>'' and shouyetupian<>'null'  and shouyetupian  like '%.jpg' order by id desc", 1, 6);
        int i = co.size();

        int j = 0;
        for (HashMap b : co) {
            j++;
            int id = Integer.parseInt(b.get("id").toString());
            String title = Info.subStr(b.get("biaoti").toString(), 21);

	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 {
            if (j == i) {
                thePics1.append(url.replaceAll("\n", ""));
                theLinks1.append("gg_detail.jsp?id=" + b.get("id"));
                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 HashMap getmap(String id, String table) {
        List<HashMap> list = new ArrayList();
        try {
            Statement st = conn.createStatement();
            //System.out.println("select * from "+table+" where id="+id);
            ResultSet rs = st.executeQuery("select * from " + table + " where id=" + id);
            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")) {
                        String str = rs.getString(j) == null ? "" : rs.getString(j);
                        if (str.equals("null")) str = "";
                        map.put(rsmd.getColumnName(j), str);
                    } else
                        map.put("id", rs.getString(j));
                }
                list.add(map);
            }
            rs.close();
            st.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list.get(0);
    }

    public HashMap getmaps(String nzd, String zdz, String table) {
        List<HashMap> list = new ArrayList();
        try {
            Statement st = conn.createStatement();
                Statement st = conn.createStatement();
                for (String str : collist) {
                    if (names.indexOf("," + str + ",") > -1) {
                        String[] values = request.getParameterValues(str);
                        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-" + str + "-value") != null) {
                                String dkv = request.getParameter(vstr);
                                String dknamevalue = request.getParameter("dk-" + str + "-value");
                                vstr += " - " + dknamevalue + ":" + dkv;
                            }

                            value += vstr + " ~ ";

                        }
                        if (value == null) value = "";
                        if (value.equals("null")) value = "";
                        if (value.length() > 0) value = value.substring(0, value.length() - 3);

                        if (typemap.get(str + "---").equals("int")) {
                            sql += (value.equals("") ? -10 : value) + ",";
                        } else {
                            sql += "'" + (value.equals("null") ? "" : value) + "',";
                        }
                    } else {
                        if (typemap.get(str + "---").equals("int")) {
                            sql += (extmap.get(str) == null ? "" : extmap.get(str)) + ",";
                        } else {
                            sql += "'" + (extmap.get(str) == null ? "" : extmap.get(str)) + "',";
                        }
                    }
                }

                sql = sql.substring(0, sql.length() - 1) + ")";
                System.out.println(sql);
                this.commOper(sql);

                st.close();

            } 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";
			      try {
			       fileItem.write(newFile);
			      } catch (Exception e) {
			       e.printStackTrace();
			      }
			     }else{
			     }
			    }
			}
			
			go("/js/uploaddoc3.jsp?docname="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			    }
		}
		
		//导excel
		if(ac.equals("importexcel"))
		{
			String page = request.getParameter("page");
			String whzdstr = request.getParameter("whzdstr");
			String tablename = request.getParameter("tablename");
			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());
			     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/uploaddoc3.jsp?docname="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			    }
		}
		
		//导excel
		if(ac.equals("importexcel"))
		{
			String page = request.getParameter("page");
			String whzdstr = request.getParameter("whzdstr");
			String tablename = request.getParameter("tablename");
			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){
		 String checkbox="";
		 for(HashMap permap:new CommDAO().select("select * from "+tablename+" where "+where+" order by id desc")){ 
			 
			 String optionstr = "'";
			 for(String str:zdname.split(";"))
			 {
				 if(str.indexOf("~")>-1){
				 String zdstr = str.split("~")[0];
				 String zdnamestr = str.split("~")[1].equals("无名")?"":(str.split("~")[1]+":");
				 optionstr+=zdnamestr+permap.get(zdstr)+" - ";
				 }else{ 
					 optionstr+=permap.get(str); 
				 }
			 }
			 if(optionstr.length()>0)optionstr=optionstr.substring(0,optionstr.length()-3);
			 optionstr+="',";
			 checkbox+= optionstr;
		 }
		 if(checkbox.length()>0)checkbox=checkbox.substring(0,checkbox.length()-1);
		 
		 return checkbox;
	 }
	 
	 
	 
	 
	 public static String getcheckboxDk(String name,String tablename,String zdname,String nstr,String where)
	 { 
		 String checkbox="";
		 int i=0;
		 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];
				 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);
			 String nbs = "";
			 if(i>0)nbs="&nbsp;";
			 checkbox+="<label>"+nbs+"<input type='checkbox' name='"+name+"' value=\""+optionstr+"\">"+optionstr+"</label>&nbsp;&nbsp;\n";
			 checkbox+="<label>&nbsp;- "+nstr+" &nbsp;<input type='text' size='5' name='"+optionstr+"' value=\"\"></label><br />\n";
			 i++;
		 }
		 checkbox+="<input type=hidden name='"+name+"' value='' /><input type=hidden name='dk-"+name+"-value' value='"+nstr+"' />";

	// 当前页数
	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;
	        }
	        
			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{
	    	   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];
	    	  
	    	  jscode+=" }\n";
	    	  jscode+=" }\n";
	    	  jscode+=" }\n";
	    	  
	    	  jscode+=" if(radios.type=='select'){\n";
	    	  jscode+=" "+formname+"."+str1+".value=\""+str2+"\";\n";
	    	  jscode+=" }\n";
	    	  
	    	  
	    	  jscode+=" }else{\n";
	    	  jscode+=" if("+formname+"."+str1+")\n";
	    	  jscode+="{\n";
	    	  jscode+=""+formname+"."+str1+".value=\""+str2+"\";\n";
	    	  jscode+="}\n";
	    	  jscode+="}\n";
	    	  
	    	
	    	  jscode+="if(document.getElementById(\"txt\"))\n";
	    	  jscode+="{\n";
	    	  jscode+="document.getElementById(\"txt\").src=\"upfile/"+map.get("filename")+"\";\n";
	    	  jscode+="}\n";
	    	  
	    	  jscode+="if(document.getElementById(\"txt2\"))\n";
	    	  jscode+="{\n";
	    	  jscode+="document.getElementById(\"txt2\").src=\"upfile/"+map.get("filename2")+"\";\n";
	    	  jscode+="}\n";
	    	  
	    	  jscode+="if(document.getElementById(\"txt3\"))\n";
	    	  jscode+="{\n";
	    	  jscode+="document.getElementById(\"txt3\").src=\"upfile/"+map.get("filename3")+"\";\n";
	    	  jscode+="}\n";
	    	  
	    	  jscode+="if(document.getElementById(\"txt4\"))\n";
	    	  jscode+="{\n";
	    	  jscode+="document.getElementById(\"txt4\").src=\"upfile/"+map.get("filename4")+"\";\n";
	    	  jscode+="}\n";
	    	  
	    	  jscode+="if(document.getElementById(\"txt5\"))\n";
	    	  jscode+="{\n";
	    	  jscode+="document.getElementById(\"txt5\").src=\"upfile/"+map.get("filename5")+"\";\n";
	    	  jscode+="}\n";
	    	  
			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/uploaddoc.jsp?docname="+filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			    }
		}
		
		
		if(ac.equals("uploaddoc2"))
		{
			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);
                } else {
                    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) {
            // TODO Auto-generated catch block
            e.printStackTrace();

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值