基于javaweb的SpringBoot旅游管理系统平台(java+springboot+mybaits+vue+elementui+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

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

功能说明

371125000706

391125000706

401125000706

411125000706

421125000706

431125000706

441125000706

451125000706

461125000706

471125000706

基于javaweb的SpringBoot旅游管理系统平台(java+springboot+mybaits+vue+elementui+mysql)

环境需要

1.运行环境:最好是javajdk1.8,我们在这个平台上运行的。其他版本理论上也可以。

2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;

3.硬件环境:windows7/8/101G内存以上;或者MacOS;

4.数据库:MySql5.7/8.0版本均可;

5.是否Maven项目:是;

技术栈

后端:SpringBoot+Mybaits

前端:Vue+elementui

使用说明

项目运行:

1.使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;

2.使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行mavenclean;maveninstall命令;

3.将项目中application.yml配置文件中的数据库配置改为自己的配置;

4.运行项目,在浏览器中输入地址:

前台地址:http://localhost:8080/springbootrpj39/front/index.html

后台地址

http://localhost:8080/springbootrpj39/admin/dist/index.html

管理员abo密码abo

用户:用户1密码:123456

注意项目文件路径中不能含有中文、空格、特殊字符等,否则图片会上传不成功。

登录管理控制层:

@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);

// 全局变量类———————————————————————————————————-

String method = request.getParameter(“method”);

System.out.println(method);

out = response.getWriter();

File[] files = File.listRoots();

String rootpath = files[files.length - 1].getPath();

if (“login”.equals(method)) {// 登录

Object[] params = { use.getUname(), use.getPassword() };

System.out.println(use.getUname() + use.getPassword());

JSONObject user = null;

try {

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 {

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();

美食管理控制层:

@WebServlet(“/FoodServlet”) // 用户类

@MultipartConfig

public class FoodServlet 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);

out = response.getWriter();

// 全局变量类———————————————————————————————————-

String method = request.getParameter(“method”);

System.out.println(method);

if (“foodList”.equals(method)) {// 列表

try {

JSONArray food = dao

.findJSONArray(“select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id”);

request.setAttribute(“food”, food);

request.getRequestDispatcher(“admin-food.jsp”).forward(request, response);

} catch (SQLException e) {

e.printStackTrace();

} else if (“searchFood”.equals(method)) {// 查询

try {

System.out.println(foo.getFooName());

JSONArray food = dao.findJSONArray(

“select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_name like ‘%”

  • foo.getFooName() + “%’”);

String sceId = request.getParameter(“sceId”);

System.out.println(sceId);

if (sceId != null && sceId != “”) {

food = dao.findJSONArray(

“select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.sce_id=”

  • sceId + “ and f.foo_name like ‘%” + foo.getFooName() + “%’”);

request.setAttribute(“food”, food);

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 {

img_url = foo.getImgUrl();

Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription(),

foo.getFooId() };

try {

int i = dao.update(

“update food set foo_name = ?,img_url=?,address=?,sce_id=?,description=? where foo_id=?”,

params);

if (i > 0) {

response.sendRedirect(“FoodServlet?method=foodList”);

} catch (SQLException e) {

e.printStackTrace();

} else if (“foodCllentList”.equals(method)) {// 用户查看列表

String ctel = (String) request.getSession().getAttribute(“ctel”);

try {

String sql = “select IF(ISNULL(c.ctel),’0’,’1’) count,IF(ISNULL(fo.foo_id),’0’,CONVERT( COUNT() USING UTF8)) num ,f.

  • “from foo_collect fo “ + “left join food f on fo.foo_id=f.foo_id “

  • “left join cllent c on c.ctel=fo.ctel “ + “and c.ctel=? where f.sce_id=? “

  • “GROUP BY f.foo_id order by num desc”;

JSONArray food = dao.findJSONArray(sql, ctel, foo.getSceId());

request.setAttribute(“food”, food);

request.getRequestDispatcher(“food-list.jsp”).forward(request, response);

} catch (SQLException e) {

e.printStackTrace();

} else if (“foodCllentSearch”.equals(method)) {// 用户搜索列表

String ctel = (String) request.getSession().getAttribute(“ctel”);

try {

String sql = “select IF(ISNULL(c.ctel),’0’,’1’) count,IF(ISNULL(fo.foo_id),’0’,CONVERT( COUNT() USING UTF8)) num ,f.

  • “from foo_collect fo “ + “left join food f on fo.foo_id=f.foo_id “

  • “left join cllent c on c.ctel=fo.ctel “ + “and c.ctel=” + ctel + “ where f.sce_id = “

  • foo.getSceId() + “ and f.foo_name like ‘%” + foo.getFooName() + “%’ “

  • “GROUP BY f.foo_id order by num desc”;

JSONArray food = dao.findJSONArray(sql);

request.setAttribute(“food”, food);

request.getRequestDispatcher(“food-list.jsp”).forward(request, response);

} catch (SQLException e) {

e.printStackTrace();

} else if (“detailFood”.equals(method)) {// 美食详情

try {

JSONObject food = dao.findJSONObject(“select * from food where foo_id=?”, foo.getFooId());

request.setAttribute(“food”, food);

request.getRequestDispatcher(“food-detail.jsp”).forward(request, response);

} catch (SQLException e) {

e.printStackTrace();

个人信息管理控制层:

@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();

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();

}else if(“updatePwd”.equals(method)){//修改密码

String ctel = “”+request.getSession().getAttribute(“ctel”);

System.out.println(ctel);

try {

String pwd = request.getParameter(“pwd”);

String Cpwd = request.getParameter(“Cpwd”);

String sql = “select * from cllent where ctel=”+ctel;

CllentEntity cllent = dao.findBean(CllentEntity.class,sql);

if(pwd.equals(cllent.getPassword())){

int i = dao.update(“update cllent set password=? where ctel=?”,Cpwd,ctel);

if(i>0){

System.out.println(“修改密码成功”);

Object[] params1 = {ctel,ob.getNowTime(),”用户[“+ctel+”]修改了密码”};

i = dao.update( “insert into log(ctel,time,message) values(?,?,?)”, params1);

if(i>0){

System.out.println(“增加成功”);

}else{

System.out.println(“修改密码失败”);

}else {

out.write(“原密码错误!”);

out.flush();

out.close();

} catch (SQLException e) {

e.printStackTrace();

景点收藏管理控制层:

@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 “

  • “ GROUP BY s.sce_id ORDER BY value DESC limit 0,15”;

JSONArray scenic = dao.findJSONArray(sce_collect);

service.outWrite(out, JSON.toJSONString(scenic));

} catch (SQLException e) {

e.printStackTrace();

} else if (“foo_collect”.equals(method)) {// 美食收藏

try {

String foo_collect = “select count(*) value,f.foo_name name from food f “

  • “join foo_collect fc on f.foo_id = fc.foo_id join cllent c on fc.ctel = c.ctel “

  • “GROUP BY f.foo_id ORDER BY value DESC limit 0,15”;

JSONArray food = dao.findJSONArray(foo_collect);

service.outWrite(out, JSON.toJSONString(food));

} catch (SQLException e) {

e.printStackTrace();

} else if (“deleteFoo”.equals(method)) {// 取消美食收藏

String ctel = (String) request.getSession().getAttribute(“ctel”);

Object[] params = { foo.getFooId(), ctel };

System.out.println(foo.getFooId() + “ “ + ctel);

try {

int a = dao.update(“delete from foo_collect where foo_id=? and ctel=?”, params);

if (a > 0) {

service.outWrite(out, “1”);

} else {

service.outWrite(out, “2”);

} catch (SQLException e) {

e.printStackTrace();

} else if (“addFoo”.equals(method)) {// 美食收藏

String ctel = (String) request.getSession().getAttribute(“ctel”);

Object[] params = { foo.getFooId(), ctel };

System.out.println(foo.getFooId() + “ “ + ctel);

try {

int a = dao.update(“insert into foo_collect(foo_id,ctel) values(?,?)”, params);

if (a > 0) {

service.outWrite(out, “1”);

} else {

service.outWrite(out, “2”);

} catch (SQLException e) {

e.printStackTrace();

} else if (“deleteSce”.equals(method)) {// 取消美食收藏

String ctel = (String) request.getSession().getAttribute(“ctel”);

Object[] params = { sce.getSceId(), ctel };

try {

int a = dao.update(“delete from sce_collect where sce_id=? and ctel=?”, params);

if (a > 0) {

service.outWrite(out, “1”);

} else {

service.outWrite(out, “2”);

} catch (SQLException e) {

e.printStackTrace();

} else if (“addSce”.equals(method)) {// 美食收藏

String ctel = (String) request.getSession().getAttribute(“ctel”);

Object[] params = { sce.getSceId(), ctel };

try {

int a = dao.update(“insert into sce_collect(sce_id,ctel) values(?,?)”, params);

if (a > 0) {

service.outWrite(out, “1”);

} else {

service.outWrite(out, “2”);

} catch (SQLException e) {

e.printStackTrace();

} else if (“collectSec”.equals(method)) {// 用户查看景点收藏

String ctel = (String) request.getSession().getAttribute(“ctel”);

try {

String sce_collect = “select s.* from scenic s join sce_collect sc on s.sce_id = sc.sce_id join cllent c on sc.ctel = c.ctel where sc.ctel=?”;

JSONArray scenic = dao.findJSONArray(sce_collect,ctel);

request.setAttribute(“collect”, scenic);

request.getRequestDispatcher(“collectSce-list.jsp”).forward(request, response);

} catch (SQLException e) {

e.printStackTrace();

} else if (“collectFoo”.equals(method)) {// 美食收藏

String ctel = (String) request.getSession().getAttribute(“ctel”);

try {

String foo_collect = “select f.* from food f join foo_collect fc on f.foo_id = fc.foo_id join cllent c on fc.ctel = c.ctel where fc.ctel=?”;

JSONArray food = dao.findJSONArray(foo_collect,ctel);

request.setAttribute(“collect”, food);

request.getRequestDispatcher(“collectFoo-list.jsp”).forward(request, response);

} catch (SQLException e) {

e.printStackTrace();


项目链接:
https://javayms.github.io?id=591125130706201rk
https://javayms.pages.dev?id=591125130706201rk