基于Java-ssm框架和Eclipse开发工具的旅游管理网站(产品管理页面)

页面介绍

旅游管理系统基于JavaSSM框架,Maven,Mysql数据库,Bootstrap动态页面,springMVC,mybatis等,其中产品管理页面有增删改查,动态显示,分页显示,多行删除的功能。

后台代码

依赖安装(pom.xml)

pom.xml文件pom.xml作为Maven架构中用于管理:源代码、配置文件、开发者的信息和角色、问题追踪系统、组织信息、项目授权、项目的url、项目的依赖关系的文件。十分重要,首先要在pom文件中把项目所要用到的相关依赖插件安装。

项目资源配置(resource)

java项目资源配置文件夹

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/mvc
	http://www.springframework.org/schema/mvc/spring-mvc.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop.xsd">

	<!-- 开启注解扫描,管理service和dao -->
	<context:component-scan
		base-package="com.yzw.service">
	</context:component-scan>
	<context:component-scan
		base-package="com.yzw.dao">
	</context:component-scan>
	
	<context:property-placeholder location="classpath:db.properties" />
		<!-- 配置数据库数据源 -->
		<bean id="dataSource"
			class="com.mchange.v2.c3p0.ComboPooledDataSource">
			<property name="driverClass" value="${jdbc.driver}" />
			<property name="jdbcUrl" value="${jdbc.url}" />
			<property name="user" value="${jdbc.username}" />
			<property name="password" value="${jdbc.password}" />
		</bean>
		
		<!-- 创建spring工厂 -->
		<bean id="sqlSessionFactory"
			class="org.mybatis.spring.SqlSessionFactoryBean">
			<property name="dataSource" ref="dataSource" />
			
			<!-- 传入PageHelper的插件 -->
			<property name="plugins">
				<array>
					<!-- 传入插件的对象 -->
					<bean class="com.github.pagehelper.PageInterceptor">
						<property name="properties">
							<props>
								<prop key="helperDialect">mysql</prop>
								<prop key="reasonable">true</prop>
							</props>
						</property>
					</bean>
				</array>
			</property>
		</bean>
		
		<!-- 扫描dao/mapper接口文件 -->
		<bean id="mapperScanner"
			class="org.mybatis.spring.mapper.MapperScannerConfigurer">
			<property name="basePackage" value="com.yzw.dao" />
			<!-- 如果还有有些专门针对于mybatis的配置,需要引入 -->
		</bean>
		
		
</beans>

该文件用于配置数据源和过滤扫描器

db.properties

jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/pms?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&rewriteBatchedStatements=true
jdbc.username=root
jdbc.password=12345678

## P6SpyDriver
jdbc.driver=com.p6spy.engine.spy.P6SpyDriver
jdbc.url=jdbc:p6spy:mysql://localhost:3306/pms?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&rewriteBatchedStatements=true
jdbc.username=root
jdbc.password=12345678

该文件用于连接mysql数据库

log4j.properties

### 设置###
log4j.rootLogger = debug,stdout,D,E

### 输出信息到控制台 ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n

### 输出DEBUG 级别以上的日志到=D://logs/error.log ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = D://logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ]-[ %p ] %m%n

### 输出ERROR 级别以上的日志到=D://logs/error.log ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File =D://logs/error.log
log4j.appender.E.Append = true
log4j.appender.E.Threshold = ERROR
log4j.appender.E.layout = org.apache.log4j.PatternLayout

该文件用于输出错误及DEBUG日志

springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 配置包扫描 -->
<context:component-scan base-package="com.yzw.controller">
</context:component-scan>
<!-- 添加springmvc注解驱动 -->
<mvc:annotation-driven />
<!-- 配置视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- JSP文件所在的目录 -->
<property name="prefix" value="/pages/" />
<!-- 文件的后缀名 -->
<property name="suffix" value=".jsp" />
</bean>
<!--配置静态资源不过滤-->
<mvc:default-servlet-handler/>
<!--
支持AOP的注解支持,AOP底层使用代理技术
JDK动态代理,要求必须有接口
cglib代理,生成子类对象,proxy-target-class="true" 默认使用cglib的方式
-->
<aop:aspectj-autoproxy proxy-target-class="true"/>
</beans>

该文件用于配置视图解析器,从而找到页面进行显示

spy.properties

driverlist=com.mysql.jdbc.Driver
autoflush = true
appender=com.p6spy.engine.spy.appender.StdoutLogger

该文件用于监视SQL语句操作

SSM架构(Model、Controller、View)

在这里插入图片描述

数据库封装类(entity)

package com.yzw.entity;
public class Product {
		private Integer id;
		private String productNum;
		private String productName;
		private String cityName;
		private String departureTime;
		private Double productPrice;
		private String productDesc;
		private Integer productStatus;
//		1.无参和有参的构造方法
//		2.set/get
//		3.tostring方法
		
		//有参构造方法
		public Product(Integer id, String productNum, String productName, String cityName, String departureTime,
				Double productPrice, String productDesc, Integer productStatus) {
			super();
			this.id = id;
			this.productNum = productNum;
			this.productName = productName;
			this.cityName = cityName;
			this.departureTime = departureTime;
			this.productPrice = productPrice;
			this.productDesc = productDesc;
			this.productStatus = productStatus;
		}
		
		//无参构造方法
		public Product() {
			super();
		}
		
		//产品ID
		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		
		//产品编号
		public String getProductNum() {
			return productNum;
		}
		public void setProductNum(String productNum) {
			this.productNum = productNum;
		}
		
		//产品名称
		public String getProductName() {
			return productName;
		}
		public void setProductName(String productName) {
			this.productName = productName;
		}
		
		//城市名称
		public String getCityName() {
			return cityName;
		}
		public void setCityName(String cityName) {
			this.cityName = cityName;
		}
		
		//出发时间
		public String getDepartureTime() {
			return departureTime;
		}
		public void setDepartureTime(String departureTime) {
			this.departureTime = departureTime;
		}
		
		//产品价格
		public Double getProductPrice() {
			return productPrice;
		}
		public void setProductPrice(Double productPrice) {
			this.productPrice = productPrice;
		}
		
		//产品描述
		public String getProductDesc() {
			return productDesc;
		}
		public void setProductDesc(String productDesc) {
			this.productDesc = productDesc;
		}
		
		//产品状态
		public Integer getProductStatus() {
			return productStatus;
		}
		public void setProductStatus(Integer productStatus) {
			this.productStatus = productStatus;
		}
		
		//tostring方法
		@Override
		public String toString() {
			return "Product [id=" + id + ", productNum=" + productNum + ", productName=" + productName + ", cityName="
					+ cityName + ", departureTime=" + departureTime + ", productPrice=" + productPrice
					+ ", productDesc=" + productDesc + ", productStatus=" + productStatus + "]";
		}
		
		
}

将数据库中的数据进行封装,同时构建有参和无参的构造方法。
创建每个字段的get/set方法以此来进行数据的引用和添加。
构建toString()方法将封装类输出转换为String类型

在Eclipse中,通过在Prodect类中右键–>Source可以实现快速构建有参/无参、get/set、toString方法,步骤如下:
在这里插入图片描述
在这里插入图片描述
1.构建有参/无参:
在这里插入图片描述

有参为全选(selectAll),无参为全不选(deselectAll)

2.Get/Set方法
在这里插入图片描述
3.toString方法
在这里插入图片描述

数据库操作类(Dao)

package com.yzw.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.yzw.entity.Product;

public interface ProductDao {

	// 查询语句
	@Select("select * from product")
	public List<Product> selectAll();

	// 添加语句
	@Insert("insert product values(#{id},#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
	public int insertProduct(Product product);

	// 删除语句
	@Delete("delete from product where id=#{id}")
	public int deleteProduct(int id);

	// 修改语句
	@Update("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},departureTime=#{departureTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id=#{id}")
	public int updateProduct(Product product);

	// 根据id查询语句(通过id向修改页面传值)
	@Select("select * from product where id = #{id}")
	public Product selectProductById(Integer id);

	// 单行删除语句
	@Delete("delete from product where id=#{id}")
	public int deleteProductOne(Integer id);
}

Service层接口实现类(ServiceImpl)

package com.yzw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yzw.dao.ProductDao;
import com.yzw.entity.Product;
import com.yzw.service.ProductService;

@Service
public class ProductServiceImpl implements ProductService {
	// 声明变量
	@Autowired // 变量注解:不为空
	private ProductDao productDao;

	// 实体类返回DAO层的查询数据
	@Override
	public List<Product> selectAll() {
		// TODO Auto-generated method stub
		return productDao.selectAll();
	}

	@Override
	public int insertProduct(Product product) {
		// TODO Auto-generated method stub
		return productDao.insertProduct(product);
	}

	@Override
	public boolean deleteProduct(Integer[] ids) {
		// TODO Auto-generated method stub
		for (int i = 0; i < ids.length; i++) {
			productDao.deleteProduct(ids[i]);
		}
		return true;
	}

	@Override
	public int updateProduct(Product product) {
		// TODO Auto-generated method stub
		return productDao.updateProduct(product);
	}

	@Override
	public Product selectProductById(Integer id) {
		// TODO Auto-generated method stub
		return productDao.selectProductById(id);
	}

	@Override
	public int deleteProductOne(Integer id) {
		// TODO Auto-generated method stub
		return productDao.deleteProductOne(id);
	}

}

Service层接口(Service)

package com.yzw.service;

import java.util.List;

import com.yzw.entity.Product;

public interface ProductService {

	// 返回实体类的查询结果
	List<Product> selectAll();

	int insertProduct(Product product);

	boolean deleteProduct(Integer[] ids);

	int updateProduct(Product product);

	Product selectProductById(Integer id);

	int deleteProductOne(Integer id);

}

控制器层(Controller)

package com.yzw.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yzw.entity.Product;
import com.yzw.service.ProductService;

@Controller
@RequestMapping("/product")

public class ProductController {

	// 声明变量
	@Autowired // 变量注解:不为空
	private ProductService productService;

	// 只返回数据的方法
	@RequestMapping("selectAllData")
	@ResponseBody
	public PageInfo<Product> selectAllData(
			@RequestParam(name = "pageNum", defaultValue = "1", required = false) Integer pageNum,
			@RequestParam(name = "pageSize", defaultValue = "20", required = false) Integer pageSize) {
		// 1.开启分页
		PageHelper.startPage(pageNum, pageSize);
		// 2.执行查询语句
		List<Product> list = productService.selectAll();
		// 3.封装pageinfo类
		PageInfo<Product> pageInfo = new PageInfo<Product>(list);
		return pageInfo;
	}

	// 只返回页面的方法
	@RequestMapping("selectAllView")
	public ModelAndView selectAllView() {
		ModelAndView mav = new ModelAndView();
		mav.setViewName("product-list");
		return mav;
	}

	/* 2.添加产品 */
	@RequestMapping("/insertProduct")
	@ResponseBody
	public ModelAndView insertProduct(Product product) {
		ModelAndView mav = new ModelAndView();
		int flag = productService.insertProduct(product);
		if (flag == 0) {// 添加失败返回本页面
			mav.setViewName("product-add");
		} else {// 返回产品列表页面,并查询数据
				// 执行查询全部产品
			mav = selectAllView();
		}
		return mav;
	}

	/* 3.批量删除产品 */
	@RequestMapping("/deleteProducts")
	@ResponseBody
	public boolean deleteProduct(Integer[] ids) {
		return productService.deleteProduct(ids);
	}

	/* 4.单行删除产品 */
	@RequestMapping("/deleteProductOne")
	@ResponseBody
	public int deleteProductOne(Integer id) {
		return productService.deleteProductOne(id);
	}

	/* 5.修改产品 */
	@RequestMapping("/updateProduct")
	@ResponseBody
	public ModelAndView updateProduct(Integer id) {
		// 1.获取要修改的信息
		Product product = productService.selectProductById(id);
		// 2.跳转到修改页面
		ModelAndView mav = new ModelAndView();
		mav.setViewName("product-update");
		mav.addObject("product", product);
		return mav;
	}

	// 6.修改产品,返回页面
	@RequestMapping("/updateProductData")
	public ModelAndView updateProductData(Product product) {
		// 1.获取要修改的信息
		int flag = productService.updateProduct(product);
		// 2.跳转到对应页面
		ModelAndView mav = new ModelAndView();
		if (flag > 0) {// 修改成功,跳转到产品列表页面
			mav.setViewName("product-list");
		} else {// 修改失败,继续回到修改页面
			mav.setViewName("product-update");
		}
		return mav;
	}
}

数据库(Mysql)

-- 创库
drop database if exists pms;
create database pms character set utf8;
use pms;

#产品表 product
drop table if exists product;

create table product(
	
	id int(11) not null primary key auto_increment comment '主键',
	
	productNum varchar(60) not null unique comment '产品编号',
	
	productName varchar(60) comment '产品名称',
	
	cityName varchar(20) comment '出发城市',
	
	departureTime datetime comment '出发时间',
	
	productPrice double(10,2) comment '产品价格',
	
	productDesc varchar(500) comment '产品描述',
	
	productStatus int(1) comment '产品状态(0 关闭 1 开启)'

);

-- 创建存储过程pro_insertMany,循环插入数据 
drop PROCEDURE if exists pro_insertMany;
DELIMITER //
CREATE PROCEDURE pro_insertMany(IN nums INT)
BEGIN
	DECLARE i INT DEFAULT 1;
	WHILE i<=nums DO
		insert into product values(null,i,'江西武功山3日游','武汉','2020-10-24 10:00:00',1888.00,'来咯表哥',1);		
		SET i=i+1;
	END WHILE;	
END//
DELIMITER ;

-- 调用存储过程pro_insertMany,插入120条随机数据
CALL pro_insertMany(120);

select * from product;
  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一、项目简介本课程演示的是一套基于SSM实现的旅游管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Java学习者。课程包含:1. 项目源码、项目文档、数据库脚本、软件工具等所有资料2. 带你从零开始部署运行本套系统3. 该项目附带的源码资料可作为毕设使用4. 提供技术答疑二、技术实现后台框架SpringSpringMVC、MyBatisUI界面:JSP、jQuery 、BootStrap数据库:MySQL 三、系统功能本系统分为前台旅游界面和后台管理,包含三种角色:注册用户、旅游公司和管理员系统的功能模块如下: 1.登陆注册模块 管理员的登录模块:管理员登录系统对本系统其他管理模块进行管理。 用户的登录模块:用户登录本系统,对个人的信息等进行查询,操作可使用的功能。 用户注册模块:游客用户可以进行用户注册,系统会反馈是否注册成功。 添加管理员模块:向本系统中添加更多的管理人员,管理员包括普通管理员和超级管理员。 2.景点信息管理模块: 景点信息列表:将数据库的景点信息表以列表的形式呈现给管理员。 添加景点信息:实现管理员添加景点信息。 修改景点信息:实现管理员修改景点信息。 3.公告文章管理模块: 公告文章列表:将数据库的公告文章表以列表的形式呈现给管理员。 添加公告文章:实现管理员添加公告文章。 修改公告文章:实现管理员修改公告文章。 4.旅游线路管理模块: 旅游线路列表:显示系统的所有旅游线路,可以通过关键字查询。 旅游线路删除:对输入错误或过期的旅游线路删除。 5.变幻图管理模块: 变幻图列表:显示系统的所有变幻图,可以通过关键字查询。 变幻图删除:对输入错误或过期的变幻图删除。 6.用户模块: 资料管理:用户登录本系统。可以对自己的个人主页进行查看。 系统信息:用户可以查看自己的系统提示信息。 修改资料:用户可以修改自己的账号密码。 信息搜索:用户可以通过关键字搜索站内信息。 密码修改:用户可以修改个人登录密码。 7.系统管理模块 8.退出模块该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。四、项目截图1)前台首页2)旅游景点详情3)旅游线路报名4)系统后台登陆5)后台管理界面  更多Java毕设项目请关注【毕设系列课程】https://edu.csdn.net/lecturer/2104   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值