基于javaweb+mysql的jsp+servlet在线旅游美食展现管理系统(java+servlet+jsp+bootstrap+mysql)

基于javaweb+mysql的jsp+servlet在线旅游美食展现管理系统(java+servlet+jsp+bootstrap+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb的JSP+Servlet在线旅游美食展现管理系统(java+servlet+jsp+bootstrap+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版本;

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入localhost:8080/
		} else if ("deleteCllent".equals(method)) {// 删除
			try {
				int i = dao.update("delete from cllent where ctel=?", con.getCtel());
				if (i > 0 ) {
					response.sendRedirect("Cllent?method=cllentList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateCllent".equals(method)) {// 修改
			Object[] params = { con.getCllId() };
			try {
				JSONObject cllent = dao.findJSONObject("select * from cllent where cll_id = ?", params);
				request.setAttribute("cllent", cllent);
				request.getRequestDispatcher("admin-cllentUpdate.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateCllent1".equals(method)) {// 完成修改
			Object[] params = {  con.getCllName(), con.getCsex(),con.getIdCode(),con.getAge(), con.getCtel() };
			try {
				int i = dao.update("update cllent set cll_name = ?,csex=?,id_code=?,age=? where ctel=?",
						params);
				if (i > 0) {
					service.outWrite(out, "1");
				} else {
					service.outWrite(out, "2");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateCllent2".equals(method)) {// 用户完成修改信息
			Object[] params1 = { con.getCllName(), con.getCsex(),con.getIdCode(),con.getAge(), con.getCtel() };
			try {

				int i = dao.update("update cllent set cll_name = ?,csex=?,id_code=?,age=? where ctel=?",
						params1);
				if(i>0) {
					response.sendRedirect("Cllent?method=cllentList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("cllent".equals(method)) {// 用户信息
			String uname = (String) session.getAttribute("uname");
			JSONArray cllent;
			try {
				cllent = dao.findJSONArray(
						"select u.*,c.* from users u join cllent c on c.uname=u.uname where u.uname=?", uname);
				System.out.println(cllent);
				request.setAttribute("cllent", cllent);
				request.getRequestDispatcher("cllent-info.jsp").forward(request, response);
			} catch (SQLException e) {

/**
 * 首页所需servlet
 */
@WebServlet("/LiandongServlet")
public class LiandongServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");

		BaseDao dao = new BaseDaoImpl();// 数据库工具类
		ObjectService ob = new ObjectService();// 处理方法
		BaseAreaEntity bas = ob.setObject(request, BaseAreaEntity.class);
		PrintWriter out = response.getWriter();// ajax返回方法
		String method = request.getParameter("method");
		System.out.println(method);

		if ("provinceQuery".equals(method)) {// 查询省
			try {
				String sql = "SELECT  area.base_areaid,area.name FROM base_area area where 1=1 and area.parentid='0'";
				JSONArray listDept = dao.findJSONArray(sql);
				System.out.println(listDept);
				out.write(listDept.toJSONString());
				out.flush();
				out.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}

		} else if("provinceCity".equals(method)) {//查询市
			try {
				String sql = "SELECT area.base_areaid,area.name FROM base_area area where 1=1 and area.parentid=?";
				JSONArray listDept = dao.findJSONArray(sql,bas.getParentid());
				System.out.println(listDept);
				out.write(listDept.toJSONString());
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("foodAdd".equals(method)) {// 增加
			Part part = request.getPart("Savatar");
			String heads_url = service.imagepath(part);
			String img_url = heads_url;
			Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription() };
			try {
				int i = dao.update("INSERT INTO food(foo_name,img_url,address,sce_id,description) VALUES(?,?,?,?,?)",
						params);
				if (i > 0) {
					response.sendRedirect("FoodServlet?method=foodList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("deleteFood".equals(method)) {// 删除
			try {
				int i = dao.update("delete from food where foo_id=?", foo.getFooId());
				if (i > 0) {
					response.sendRedirect("FoodServlet?method=foodList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateFood".equals(method)) {// 修改
			Object[] params = { foo.getFooId() };
			try {
				JSONObject food = dao.findJSONObject(
						"select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_id = ?",
						params);
				request.setAttribute("food", food);
				request.getRequestDispatcher("admin-foodUpdate.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateFood1".equals(method)) {// 完成修改
			String img_url = null;
			Part part1 = request.getPart("Savatar");
			if (part1.getSize() > 0) {
				String savepath = service.imagepath(part1);
				img_url = savepath;
			} else {
				img_url = foo.getImgUrl();
			}
				}
//				// 判断是否有该手机号
				String Ctel = request.getParameter("ctel");
				String sql = "select * from cllent where Ctel=" + Ctel + " and password =" + cll.getPassword();
				cllent = db.findBean(CllentEntity.class, sql);
				if (cllent == null) {
					flag = "1";
					ob.outWrite(out, flag);
				} else {
					session.setAttribute("rootpath", rootpath);
					session.setAttribute("cname", cllent.getCllName());
					session.setAttribute("ctel", cllent.getCtel());
					flag = "3";
					ob.outWrite(out, flag);
				}

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

		} else if ("registe".equals(method)) {// 注册
			try {
				String flag = "0";
				String sql = "select * from cllent where ctel=" + cll.getCtel();
				cllent = db.findBean(CllentEntity.class, sql);
				if (cllent == null) {// 判断是否以存在该手机号
					sql = "insert into cllent(ctel,password,id_code) values(?,?,?)";
					Object[] params = {cll.getCtel(), cll.getPassword(),ob.getRandom() };
					int i = db.update(sql, params);
					System.out.println(i);
					if (i != 0) {
						flag="2";
						ob.outWrite(out, flag);
					}

				}else {
					flag="1";
					ob.outWrite(out, flag);
				} 
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("recover".equals(method)) {// 忘记密码
			try {
				String flag = "0";
				String sql = "select * from cllent where Ctel=" + cll.getCtel();
				cllent = db.findBean(CllentEntity.class, sql);

				if (cllent != null) {// 判断是否以存在该手机号
					sql = "select * from cllent where Ctel = ? and id_code=? ";
					cllent = db.findBean(CllentEntity.class, sql,cll.getCtel(),cll.getIdCode());

				user = dao.findJSONObject("select * from users where uname = ? and password = ?", params);
				System.out.println(user);
				System.out.println(user.get("uname"));
				System.out.println(user.get("utype"));
				request.getSession().setAttribute("uname", user.get("uname"));
				request.getSession().setAttribute("utype", user.get("utype"));
			} catch (SQLException e) {
				e.printStackTrace();
			} finally {
				if (user.size() > 0) {
					out.write("1");
					out.flush();
					out.close();
				}
			}
		} else if ("exit".equals(method)) {// 退出登录
			request.getSession().removeAttribute("uname");
			request.getSession().removeAttribute("utype");
			request.getSession().removeAttribute("rootpath");
			response.sendRedirect("login.jsp");
		} else if ("index".equals(method)) {// 进入首页
			String uname = (String) session.getAttribute("uname");
			System.out.println(uname);
			String utype = "" + session.getAttribute("utype");
			request.getSession().setAttribute("rootpath", rootpath);
			System.out.println(utype);
			if (utype.equals("1")) {
				request.getRequestDispatcher("index.jsp").forward(request, response);
			} 
		} else if ("updateUsers".equals(method)) {// 修改密码
			String pwd = request.getParameter("pwd");
			String pwd1 = request.getParameter("pwd1");
			System.out.println(pwd);
			System.out.println(pwd1);
			String uname = (String) request.getSession().getAttribute("uname");
			Object[] params = { pwd1, uname };
			try {
				int m = (int) dao.getCount("select count(*) from users where password = ?", pwd);
				if (m > 0) {
					dao.update("update users set password = ? where uname = ?", params);
					out.write("1");
					out.flush();
					out.close();
				} else {
						flag="1";
						ob.outWrite(out, flag);
					}
				} else {
					ob.outWrite(out, flag);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}

		} else if ("exit".equals(method)) {//退出页面
			request.getSession().removeAttribute("cname");
			request.getSession().removeAttribute("ctel");
			request.getSession().removeAttribute("rootpath");
			response.sendRedirect("indexfront.jsp");
		}

	}

}


		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");

		BaseDao dao = new BaseDaoImpl();// 数据库工具类
		ObjectService ob = new ObjectService();// 处理方法
		BaseAreaEntity bas = ob.setObject(request, BaseAreaEntity.class);
		PrintWriter out = response.getWriter();// ajax返回方法
		String method = request.getParameter("method");
		System.out.println(method);

		if ("provinceQuery".equals(method)) {// 查询省
			try {
				String sql = "SELECT  area.base_areaid,area.name FROM base_area area where 1=1 and area.parentid='0'";
				JSONArray listDept = dao.findJSONArray(sql);
				System.out.println(listDept);
				out.write(listDept.toJSONString());
				out.flush();
				out.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}

		} else if("provinceCity".equals(method)) {//查询市
			try {
				String sql = "SELECT area.base_areaid,area.name FROM base_area area where 1=1 and area.parentid=?";
				JSONArray listDept = dao.findJSONArray(sql,bas.getParentid());
				System.out.println(listDept);
				out.write(listDept.toJSONString());
				out.flush();
				out.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}else if("provinceCounty".equals(method)) {//查询县/区
			try {
				String sql = "SELECT area.base_areaid,area.name FROM base_area area where 1=1 and area.parentid=?";
				JSONArray listDept = dao.findJSONArray(sql,bas.getParentid());
				System.out.println(listDept);
				out.write(listDept.toJSONString());
				out.flush();
				out.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
	 * @param str1 json对象vlue数组
	 * @return 一个json形式的验证信息
	 */
	public String getValidation(String []str,String []str1){
		
		JSONObject jsonObject = new JSONObject();
		for (int i = 0; i < str.length; i++) {
			jsonObject.fluentPut(str[i], str1[i]);
		}
		return jsonObject.toString();
		
	}
	
	/**向前端返回信息
	 * @param out
	 * @param str
	 */
	public void outWrite(PrintWriter out,String str){
		out.write(str);
		out.flush();
		out.close();
		
	}
	
	
	/**
	 * 获得当前时间
	 * @return time
	 */
	public String getNowTime(){
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String time = format.format(Calendar.getInstance().getTime());
		return time;
		
	}
	
	/**
	 * 获得当前年月日
	 * @return time
	 */
	public String getDateTime(){
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String time = format.format(Calendar.getInstance().getTime());
		return time;
		
	}
	/**
	 *根据日期生成随机数
	 * @param part
	 * @return
	 */
	public String getRandom() {
//			System.out.println(currentPage1);
//			if(currentPage1!=null) {
//				currentPage=Integer.parseInt(currentPage1);
//			}
//			int pagestart = (currentPage-1)*pageSize;
//			System.out.println(pagestart);
			try {
//				int total=(int) dao.getCount("select count(*) from scenic");
//				int pages=(total%pageSize>0?total/pageSize+1:total/pageSize);
				
				JSONArray scenic = dao.findJSONArray("select IF(ISNULL(c.ctel),'0','1') count,IF(ISNULL(sc.sce_id),'0',CONVERT( COUNT(*) USING UTF8)) num ,s.* from scenic s" + 
						" left join sce_collect sc on s.sce_id=sc.sce_id " + 
						"left join cllent c on c.ctel=sc.ctel "+
						"and c.ctel="+ctel+
						" GROUP BY s.sce_id order by num desc");
				request.setAttribute("scenic", scenic);
				request.getRequestDispatcher("scenic-list.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("searchCllentList".equals(method)) {// 用户查看列表
			String ctel = (String) request.getSession().getAttribute("ctel");
			try {
				JSONArray scenic = dao.findJSONArray("select IF(ISNULL(c.ctel),'0','1') count,IF(ISNULL(sc.sce_id),'0',CONVERT( COUNT(*) USING UTF8)) num ,s.* from scenic s " + 
						" left join sce_collect sc on s.sce_id=sc.sce_id " + 
						"left join cllent c on c.ctel=sc.ctel " + 
						"and c.ctel="+ctel+ "  where s.region_id like '%" + sce.getRegionId() + "%' and  s.sce_name like '%" + sce.getSceName() + "%' " + 
						"GROUP BY s.sce_id order by num desc ");
				request.setAttribute("scenic", scenic);
				request.getRequestDispatcher("scenic-list.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("detailScenic".equals(method)) {// 美食详情
			try {
				JSONObject scenic = dao.findJSONObject("select * from scenic where sce_id=?", sce.getSceId());
				request.setAttribute("scenic", scenic);
				request.getRequestDispatcher("scenic-detail.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}

					out.write("1");
					out.flush();
					out.close();
				} else {
					out.write("2");
					out.flush();
					out.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("users".equals(method)) {// 管理员信息
			JSONArray records;
			try {
				records = dao.findJSONArray("select * from users where uname=?", use.getUname());
				request.setAttribute("records", records);
				request.getRequestDispatcher("admin-info.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

	}
}

/**
					session.setAttribute("cname", cllent.getCllName());
					session.setAttribute("ctel", cllent.getCtel());
					flag = "3";
					ob.outWrite(out, flag);
				}

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

		} else if ("registe".equals(method)) {// 注册
			try {
				String flag = "0";
				String sql = "select * from cllent where ctel=" + cll.getCtel();
				cllent = db.findBean(CllentEntity.class, sql);
				if (cllent == null) {// 判断是否以存在该手机号
					sql = "insert into cllent(ctel,password,id_code) values(?,?,?)";
					Object[] params = {cll.getCtel(), cll.getPassword(),ob.getRandom() };
					int i = db.update(sql, params);
					System.out.println(i);
					if (i != 0) {
						flag="2";
						ob.outWrite(out, flag);
					}

				}else {
					flag="1";
					ob.outWrite(out, flag);
				} 
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("recover".equals(method)) {// 忘记密码
			try {
				String flag = "0";
				String sql = "select * from cllent where Ctel=" + cll.getCtel();
				cllent = db.findBean(CllentEntity.class, sql);

				if (cllent != null) {// 判断是否以存在该手机号
					sql = "select * from cllent where Ctel = ? and id_code=? ";
					cllent = db.findBean(CllentEntity.class, sql,cll.getCtel(),cll.getIdCode());

					if (cllent!=null) {
						flag="2";
						sql = "update cllent set password=? where ctel=?";
						Object[] params = { cll.getPassword(), cll.getCtel() };
						int i = db.update(sql, params);
						sql = "insert into log(ctel,time,message) values(?,?,?)";
						Object[] params1 = { cll.getCtel(), ob.getNowTime(), "用户["+cll.getCtel()+"]重置了密码" };
						int j = db.update(sql, params1);
						if (j > 0) {
							System.out.println("增加成功");
						}
						ob.outWrite(out, flag);

@WebServlet("/CollectServlet") // 用户类
@MultipartConfig
public class CollectServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	BaseDao dao = new BaseDaoImpl();
	PrintWriter out = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		// service
		// 方法类-----------------------------------------------------------------------------------------------------
		ObjectService service = new ObjectService();
		FoodEntity foo = service.setObject(request, FoodEntity.class);
		ScenicEntity sce = service.setObject(request, ScenicEntity.class);
		out = response.getWriter();
		// 全局变量类----------------------------------------------------------------------------------------------------------
		String method = request.getParameter("method");
		System.out.println(method);

		if ("sce_collect".equals(method)) {// 景点收藏
			try {
				String sce_collect = "select count(*) value,s.sce_name name from scenic s "
						+ "join sce_collect sc on s.sce_id = sc.sce_id join cllent c on sc.ctel = c.ctel "
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		BaseDao dao = new BaseDaoImpl();
		ObjectService ob = new ObjectService();
		PrintWriter out = response.getWriter();
		CllentEntity cll = ob.setObject(request, CllentEntity.class);
		File[] files = File.listRoots();
		String rootpath = files[files.length - 1].getPath();
//======================================================================================
		String method = request.getParameter("method");
		System.out.println(method);

		if ("queryInfor".equals(method)) {//查询用户个人信息
			String ctel =""+request.getSession().getAttribute("ctel");
			System.out.println(ctel);
			try {
				String sql = "select * from cllent where ctel="+ctel;
				JSONObject cllent = dao.findJSONObject(sql);
//				System.out.println(cllent);
				request.setAttribute("cllent", cllent);
					request.getRequestDispatcher("information2.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}else if ("updateInfor".equals(method)){//修改个人信息
			
			String ctel = ""+ request.getSession().getAttribute("ctel");
			System.out.println(ctel);
			try {
				Object[] params = { cll.getCllName(), cll.getCsex(), cll.getAge(),cll.getIdCode(), ctel };
				int i = dao.update( "update cllent set cll_name=?,csex=?,age=?,id_code=? where ctel=?",
						params);
				if(i>0){
					System.out.println("修改成功");
					String sql = "insert into log(ctel,time,message) values(?,?,?)";
					Object []params1 = {ctel,ob.getNowTime(),"用户["+ctel+"]修改了个人信息"};
					int j = dao.update(sql, params1);
					if(j>0){
						response.sendRedirect("InforTwo?method=queryInfor");
					}else{
					}
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}

	}
}

/**
 * 我的信息所需servlet
 */
@WebServlet("/InforTwo")
@MultipartConfig
public class InformationTwoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		BaseDao dao = new BaseDaoImpl();
		ObjectService ob = new ObjectService();
		PrintWriter out = response.getWriter();
		// 全局变量类----------------------------------------------------------------------------------------------------------
		String method = request.getParameter("method");
		System.out.println(method);
		int currentPage=1;
		if ("scenicList".equals(method)) {// 列表
			try {
				JSONArray scenic = dao.findJSONArray("select * from scenic");
				request.setAttribute("scenic", scenic);
				request.getRequestDispatcher("admin-scenic.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("scenic".equals(method)) {// 列表
			try {
				JSONArray scenic = dao.findJSONArray("select * from scenic");
				service.outWrite(out, scenic.toString());
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("searchScenic".equals(method)) {// 查询
			try {
				JSONArray scenic = dao
						.findJSONArray("select * from scenic where sce_name like '%" + sce.getSceName() + "%'");
				request.setAttribute("scenic", scenic);
				request.getRequestDispatcher("admin-scenic.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("scenicAdd".equals(method)) {// 增加
			Part part = request.getPart("Savatar");
			String heads_url = service.imagepath(part);
			String img_url = heads_url;
			System.out.println(sce.getRegionId());
			Object[] params = { sce.getSceName(), sce.getRegionId(), img_url, sce.getAddress(), sce.getDescription() };
			try {
				int i = dao.update(
						"INSERT INTO scenic(sce_name,region_id,img_url,address,description) VALUES(?,?,?,?,?)", params);
				if (i > 0) {
					response.sendRedirect("ScenicServlet?method=scenicList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
				request.getRequestDispatcher("admin-food.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("foodAdd".equals(method)) {// 增加
			Part part = request.getPart("Savatar");
			String heads_url = service.imagepath(part);
			String img_url = heads_url;
			Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription() };
			try {
				int i = dao.update("INSERT INTO food(foo_name,img_url,address,sce_id,description) VALUES(?,?,?,?,?)",
						params);
				if (i > 0) {
					response.sendRedirect("FoodServlet?method=foodList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("deleteFood".equals(method)) {// 删除
			try {
				int i = dao.update("delete from food where foo_id=?", foo.getFooId());
				if (i > 0) {
					response.sendRedirect("FoodServlet?method=foodList");
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateFood".equals(method)) {// 修改
			Object[] params = { foo.getFooId() };
			try {
				JSONObject food = dao.findJSONObject(
						"select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_id = ?",
						params);
				request.setAttribute("food", food);
				request.getRequestDispatcher("admin-foodUpdate.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else if ("updateFood1".equals(method)) {// 完成修改
			String img_url = null;
			Part part1 = request.getPart("Savatar");
			if (part1.getSize() > 0) {
				String savepath = service.imagepath(part1);
				img_url = savepath;
			} else {
				e.printStackTrace();
			}
		} else if ("users".equals(method)) {// 管理员信息
			JSONArray records;
			try {
				records = dao.findJSONArray("select * from users where uname=?", use.getUname());
				request.setAttribute("records", records);
				request.getRequestDispatcher("admin-info.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

	}
}

/**
 * 我的信息所需servlet
 */
@WebServlet("/InforTwo")
@MultipartConfig
public class InformationTwoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

				e.printStackTrace();
			}

		} else if ("exit".equals(method)) {//退出页面
			request.getSession().removeAttribute("cname");
			request.getSession().removeAttribute("ctel");
			request.getSession().removeAttribute("rootpath");
			response.sendRedirect("indexfront.jsp");
		}

	}

}

@WebServlet("/Login")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	BaseDao dao = new BaseDaoImpl();
	PrintWriter out = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		// service
		// 方法类-----------------------------------------------------------------------------------------------------
		ObjectService service = new ObjectService();
		HttpSession session = request.getSession();
		UsersEntity use = service.setObject(request, UsersEntity.class);
		// 全局变量类----------------------------------------------------------------------------------------------------------

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

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值