——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
前台用户+后台管理











基于javaweb的JSP+Servlet在线旅游旅行综合服务平台(java+mysql+jsp+servlet)
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| 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{ DATE1 = DATE1+"-"+d1[2]; } String[] d2 = DATE2.split("-");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| e.printStackTrace(); } }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String ac = request.getParameter("ac"); if(ac==null)ac=""; CommDAO dao = new CommDAO(); String date = Info.getDateStr(); String today = date.substring(0,10); String tomonth = date.substring(0,7); if(ac.equals("login")) { String username = request.getParameter("username"); String password = request.getParameter("pwd1"); String utype = request.getParameter("cx"); String pagerandom = request.getParameter("pagerandom")==null?"":request.getParameter("pagerandom"); String random = (String)request.getSession().getAttribute("random"); if(!pagerandom.equals(random)&&request.getParameter("a")!=null) { request.setAttribute("random", ""); go("/index.jsp", request, response); } else{ String sql1=""; if (utype.equals("注册用户")) { sql1 = "select * from yonghuzhuce where yonghuming='"+username+"' and mima='"+password+"' and issh='是'"; } else { sql1 = "select * from yuangongxinxi where gonghao='"+username+"' and mima='"+password+"'"; } List<HashMap> userlist1 = dao.select(sql1); if(userlist1.size()==1) { if (utype.equals("注册用户")) {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| 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"; if (alert) { str += "alert('操作成功');\n"; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| 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/db?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) { e.printStackTrace(); } return i; }
public double getDouble(String sql) { double i = 0; try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); if (rs.next()) { i = rs.getDouble(1);
} st.close(); } catch (SQLException e) { e.printStackTrace(); } return i;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| optionstr+=zdnamestr+permap.get(zdstr)+" - "; } } if(optionstr.indexOf(" - ")>-1)optionstr=optionstr.substring(0,optionstr.length()-3); select+="<option value=\""+optionstr+"\">"+optionstr+"</option>"; } select+="</select>"; return select; }
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("@");
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=461422482212200xh
https://javayms.pages.dev?id=461422482212200xh