基于javaweb+mysql的ssm+maven电影院购票系统(java+ssm+jsp+bootstrap+layui+echarts+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven电影院购票系统(java+ssm+jsp+bootstrap+layui+echarts+mysql)
项目介绍
影院购票系统,本项目分为前台和后台,用户有普通用户和管理员,普通用户只可访问前台页面,管理员可以访问后台; 前台主要功能: 电影分类、电影排行、电影详细介绍、选座购票、评论等功能;
后台主要功能: 用户管理、电影管理、订单管理、评论管理、标签管理、放映厅管理、场次安排等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 8.x,9.x版本均可 注:不可使用tomcat7.0,会造成图片显示异常等问题; 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;
技术栈
- 后端:spring + spring mvc + mybatis + spring security 2. 前端:JSP+jQuery+bootstrap+layui+echarts
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置; 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
return "seat";
}
@RequestMapping("/buy")
public String buy(Msm msm){
tMovieorderService.insert(msm);
System.out.println(msm);
return "redirect:/userorder/findorder?page=1&pagesize=2";
}
@RequestMapping("/findorder")
public String findByusername(int page,int pagesize,ModelMap modelMap){
String name = SecurityContextHolder.getContext().getAuthentication().getName();
TUserinfo userByname = tUserinfoService.findUserByname(name);
Integer count = tMovieorderService.count(name);
Page pagein=new Page();
pagein.setPageSize(pagesize);
pagein.setPage(page);
pagein.setCount(count);
List<TMovieorder> byUsername = tMovieorderService.findByUsername(name,page,pagesize);
PageInfo pageInfo=new PageInfo(byUsername);
modelMap.addAttribute("orders",pageInfo);
modelMap.addAttribute("pages",pagein);
modelMap.addAttribute("me",userByname);
return "user_order";
}
@RequestMapping("/cancel")
public String cancel(Integer orderid){
TMovieorder t=new TMovieorder();
t.setOrderid(orderid);
t.setStatus(3);
tMovieorderService.update(t);
return "redirect:/userorder/findorder?page=1&pagesize=2";
}
}
@Controller
@RequestMapping("/sysUser")
public class SysUsercontroller {
@Autowired
private TUserinfoService tUserinfoService;
@RequestMapping("/findall")
public String findall(Integer page,Integer pageSize,ModelMap modelMap){
List<TUserinfo> findall = tUserinfoService.findall(page,pageSize);
Integer count=tUserinfoService.count();
PageInfo<TUserinfo> pageInfo=new PageInfo<>(findall);
Page page1=new Page(pageSize,page,count);
modelMap.addAttribute("users",pageInfo);
modelMap.addAttribute("pages",page1);
return "sysUser";
}
@RequestMapping("/add")
public String add(HttpServletRequest request, MultipartFile photo, TUserinfo tUserinfo) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
System.out.println(path);
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tUserinfo.setUserphoto(movieP);
tUserinfo.setRegtime(DateUtils.getDate(new Date()));
tUserinfo.setPassword(BCPassward.setPassword(tUserinfo.getPassword()));
tUserinfoService.insert(tUserinfo);
photo.transferTo(new File(path,filename));
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
@RequestMapping("/delete")
public String delete(String name){
@Controller
public class PayController {
@Autowired
private TMovieorderService tMovieorderService;
private static String out_trade_no;
@RequestMapping("/success")
public String success(){
//修改订单状态
TMovieorder t=new TMovieorder();
t.setOrderid(Integer.parseInt(out_trade_no));
t.setStatus(1);
tMovieorderService.update(t);
return "redirect:/userorder/findorder?page=1&pagesize=2";
}
@RequestMapping("/pay")
public void payController(HttpServletRequest request, HttpServletResponse response) throws IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
//获得初始化的AlipayClient
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
//设置请求参数
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
@Override
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
RequestCache requestCache = new HttpSessionRequestCache();
String url = null;
SavedRequest savedRequest = requestCache.getRequest(httpServletRequest,httpServletResponse);
if(savedRequest != null){
url = savedRequest.getRedirectUrl();
System.out.println("URL:" + url);
}
if(url == null){
httpServletResponse.sendRedirect("index.jsp");
} else {
httpServletResponse.sendRedirect(url);
}
}
}
public class CaptchaFilter extends HttpPutFormContentFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
// 判断session当中的验证码 与 用户输入的验证码是否一致
// 如果不加判断,它会过滤全部的请求
String uri = request.getRequestURI();
if (uri.contains("/login")) {
String sessionCode = (String) request.getSession().getAttribute("captcha");
String userCode = request.getParameter("captcha");
if (StringUtils.isEmpty(userCode)) {
response.sendRedirect("login.jsp");
return;
}
if (!sessionCode.equalsIgnoreCase(userCode)) {
response.sendRedirect("login.jsp");
return;
}
}
super.doFilterInternal(request, response, filterChain);
}
}
}
@RequestMapping("/cancel")
public String cancel(Integer orderid){
TMovieorder t=new TMovieorder();
t.setOrderid(orderid);
t.setStatus(3);
tMovieorderService.update(t);
return "redirect:/userorder/findorder?page=1&pagesize=2";
}
}
@Controller
@RequestMapping("/sysOrder")
public class SysOrderController {
@Autowired
private TMovieorderService tMovieorderService;
@RequestMapping("findAll")
public String findAll(Integer page, Integer pageSize, ModelMap modelMap) {
List<TMovieorder> tMovieorders = tMovieorderService.findAll(page, pageSize);
Integer count = tMovieorderService.count();
Page page1 = new Page();
page1.setPageSize(pageSize);
page1.setPage(page);
page1.setCount(count);
PageInfo<TMovieorder> pageInfo = new PageInfo<>(tMovieorders);
modelMap.addAttribute("pages", page1);
modelMap.addAttribute("orders", pageInfo);
Page page1=new Page(pageSize,page,count);
List<TMoviehall> all = tMoviehallService.findAll(null);
modelMap.addAttribute("movies",pageInfo);
modelMap.addAttribute("pages",page1);
modelMap.addAttribute("halls",all);
return "sysmovie";
}
@RequestMapping("/delete")
public String delete(Integer id){
tMovieService.deleteById(id);
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
}
@RequestMapping("/toAdd")
public String toAdd(ModelMap modelMap){
List<TSort> all = tSortService.findAll(null);
modelMap.addAttribute("sorts",all);
return "movie_add";
}
@RequestMapping("/add")
public String add(HttpServletRequest request,MultipartFile photo,TMovie tMovie) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tMovie.setMoviephoto(movieP);
System.out.println(tMovie);
tMovieService.insert(tMovie);
photo.transferTo(new File(path,filename));
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
}
@RequestMapping("/toEdit")
public String toEdit(Integer id,ModelMap modelMap){
TMovie tMovie = tMovieService.queryById(id);
List<TSort> notByMid = tSortService.findNotByMid(id);
modelMap.addAttribute("movie",tMovie);
modelMap.addAttribute("sorts",notByMid);
return "movie_edit";
}
@RequestMapping("/edit")
public String edit(TMovie tMovie){
tMovieService.updateMs(tMovie);
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
public class CaptchaFilter extends HttpPutFormContentFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
// 判断session当中的验证码 与 用户输入的验证码是否一致
// 如果不加判断,它会过滤全部的请求
String uri = request.getRequestURI();
if (uri.contains("/login")) {
String sessionCode = (String) request.getSession().getAttribute("captcha");
String userCode = request.getParameter("captcha");
if (StringUtils.isEmpty(userCode)) {
response.sendRedirect("login.jsp");
return;
}
if (!sessionCode.equalsIgnoreCase(userCode)) {
response.sendRedirect("login.jsp");
return;
}
}
super.doFilterInternal(request, response, filterChain);
}
}
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private TUserinfoService tUserinfoService;
@RequestMapping("/find")
public String findme(ModelMap modelMap){
modelMap.addAttribute("sorts",notByMid);
return "movie_edit";
}
@RequestMapping("/edit")
public String edit(TMovie tMovie){
tMovieService.updateMs(tMovie);
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
}
@RequestMapping("/putShelf")
public String putShelf(TSchedule tSchedule){
tScheduleService.insert(tSchedule);
return "redirect:/sysSchedule/findAll?page=1&pageSize=8";
}
@RequestMapping("/show")
public @ResponseBody
List<TMovie> show(){
List<TMovie> findall = tMovieService.findall();
return findall;
}
@RequestMapping("/sortHit")
public @ResponseBody
List<TSort> sortHit(){
List<TSort> tSorts = tMovieService.countHit();
return tSorts;
}
@RequestMapping("/findSome")
public String findSome(TMovie tMovie,ModelMap modelMap,Integer page,Integer pageSize){
List<TMovie> movies=tMovieService.findSome(tMovie,page,pageSize);
PageInfo<TMovie> pageInfo=new PageInfo<>(movies);
modelMap.addAttribute("movies",pageInfo);
return "sysmovie";
}
}
@Controller
@Controller
@RequestMapping("/sysUser")
public class SysUsercontroller {
@Autowired
private TUserinfoService tUserinfoService;
@RequestMapping("/findall")
public String findall(Integer page,Integer pageSize,ModelMap modelMap){
List<TUserinfo> findall = tUserinfoService.findall(page,pageSize);
Integer count=tUserinfoService.count();
PageInfo<TUserinfo> pageInfo=new PageInfo<>(findall);
Page page1=new Page(pageSize,page,count);
modelMap.addAttribute("users",pageInfo);
modelMap.addAttribute("pages",page1);
return "sysUser";
}
@RequestMapping("/add")
public String add(HttpServletRequest request, MultipartFile photo, TUserinfo tUserinfo) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
System.out.println(path);
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tUserinfo.setUserphoto(movieP);
tUserinfo.setRegtime(DateUtils.getDate(new Date()));
tUserinfo.setPassword(BCPassward.setPassword(tUserinfo.getPassword()));
tUserinfoService.insert(tUserinfo);
photo.transferTo(new File(path,filename));
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
@RequestMapping("/delete")
public String delete(String name){
tUserinfoService.deleteById(name);
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
sort.setSorts(sorts);
modelMap.addAttribute("sort",sort);
return "sysSort_edit";
}
@RequestMapping("/edit")
public String edit(TSort tSort){
tSortService.update(tSort);
return "redirect:/sysSort/findAll?page=1&pageSize=5";
}
}
@Controller
@RequestMapping("/sysHall")
public class SysMovieHallController {
@Autowired
private TMoviehallService tMoviehallService;
@RequestMapping("/findAll")
public String finAll(ModelMap modelMap){
List<TMoviehall> all = tMoviehallService.findAll(null);
modelMap.addAttribute("halls",all);
return "sysMovieHall";
}
@RequestMapping("/add")
public String add(TMoviehall tMoviehall){
tMoviehallService.insert(tMoviehall);
return "redirect:/sysHall/findAll";
}
@RequestMapping("/delete")
public String delete(Integer id){
tMoviehallService.deleteById(id);
return "redirect:/sysHall/findAll";
}
@RequestMapping("/toedit")
public String toedit(Integer id,String name,Integer rows,Integer cols,ModelMap modelMap){
TMoviehall tMoviehall = new TMoviehall();
tMoviehall.setMoviehallid(id);
tMoviehall.setMoviehallname(name);
tMoviehall.setRows(rows);
tMoviehall.setCols(cols);
@RequestMapping("/add")
public String add(HttpServletRequest request,MultipartFile photo,TMovie tMovie) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tMovie.setMoviephoto(movieP);
System.out.println(tMovie);
tMovieService.insert(tMovie);
photo.transferTo(new File(path,filename));
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
}
@RequestMapping("/toEdit")
public String toEdit(Integer id,ModelMap modelMap){
TMovie tMovie = tMovieService.queryById(id);
List<TSort> notByMid = tSortService.findNotByMid(id);
modelMap.addAttribute("movie",tMovie);
modelMap.addAttribute("sorts",notByMid);
return "movie_edit";
}
@RequestMapping("/edit")
public String edit(TMovie tMovie){
tMovieService.updateMs(tMovie);
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
}
@RequestMapping("/putShelf")
public String putShelf(TSchedule tSchedule){
tScheduleService.insert(tSchedule);
return "redirect:/sysSchedule/findAll?page=1&pageSize=8";
}
@RequestMapping("/show")
public @ResponseBody
List<TMovie> show(){
List<TMovie> findall = tMovieService.findall();
return findall;
}
@RequestMapping("/sortHit")
public @ResponseBody
List<TSort> sortHit(){
List<TSort> tSorts = tMovieService.countHit();
return tSorts;
}
@RequestMapping("/findSome")
public String findSome(TMovie tMovie,ModelMap modelMap,Integer page,Integer pageSize){
List<TMovie> movies=tMovieService.findSome(tMovie,page,pageSize);
PageInfo<TMovie> pageInfo=new PageInfo<>(movies);
String path = request.getSession().getServletContext().getRealPath("/");
System.out.println(path);
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tUserinfo.setUserphoto(movieP);
tUserinfo.setRegtime(DateUtils.getDate(new Date()));
tUserinfo.setPassword(BCPassward.setPassword(tUserinfo.getPassword()));
tUserinfoService.insert(tUserinfo);
photo.transferTo(new File(path,filename));
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
@RequestMapping("/delete")
public String delete(String name){
tUserinfoService.deleteById(name);
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
@RequestMapping("/toedit")
public String toedit(String name,ModelMap modelMap){
TUserinfo userByname = tUserinfoService.findUserByname(name);
modelMap.addAttribute("user",userByname);
return "sysUser_edit";
}
@RequestMapping("/edit")
public String edit(HttpServletRequest request, MultipartFile photo, TUserinfo tUserinfo) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
path=path+"/static/image";
String filename = photo.getOriginalFilename();
if(filename != null&&filename != ""){
System.out.println(filename);
String movieP="/static/image/"+filename;
photo.transferTo(new File(path,filename));
tUserinfo.setUserphoto(movieP);
}
tUserinfo.setRegtime(DateUtils.getDate(new Date()));
tUserinfoService.update(tUserinfo);
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
}
}
List<TMovie> bysort2 = tMovieService.findBysort(2);
for (int i = 0; i < 8; i++) {
TMovie tMovie = bysort2.get(i);
movieList2.add(tMovie);
}
List<TMovie> findall = tMovieService.findall();
for (int i = 0; i < 6; i++) {
TMovie tMovie = findall.get(i);
movieList3.add(tMovie);
}
List<TMovie> topBysortl = tMovieService.findTopBysort(1, 0, 5);
List<TMovie> topBysortr = tMovieService.findTopBysort(1, 5, 5);
List<TMovie> topBysortl1 = tMovieService.findTopBysort(2, 0, 5);
List<TMovie> topBysortr1 = tMovieService.findTopBysort(2, 5, 5);
modelMap.addAttribute("movies", movies);
modelMap.addAttribute("comedy", movieList);
modelMap.addAttribute("l", topBysortl);
modelMap.addAttribute("r", topBysortr);
modelMap.addAttribute("actions", movieList2);
modelMap.addAttribute("l1", topBysortl1);
modelMap.addAttribute("r1", topBysortr1);
modelMap.addAttribute("all", movieList3);
return "movies_home";
}
/**
* 分类查询
*/
@RequestMapping("/findBys")
public String findByS(Integer sid,Integer page,Integer pageSize,ModelMap modelMap){
List<TSort> all = tSortService.findAll(null);
if (sid==0){
private TUserinfoService tUserinfoService;
@RequestMapping("/findall")
public String findall(Integer page,Integer pageSize,ModelMap modelMap){
List<TUserinfo> findall = tUserinfoService.findall(page,pageSize);
Integer count=tUserinfoService.count();
PageInfo<TUserinfo> pageInfo=new PageInfo<>(findall);
Page page1=new Page(pageSize,page,count);
modelMap.addAttribute("users",pageInfo);
modelMap.addAttribute("pages",page1);
return "sysUser";
}
@RequestMapping("/add")
public String add(HttpServletRequest request, MultipartFile photo, TUserinfo tUserinfo) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
System.out.println(path);
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tUserinfo.setUserphoto(movieP);
tUserinfo.setRegtime(DateUtils.getDate(new Date()));
tUserinfo.setPassword(BCPassward.setPassword(tUserinfo.getPassword()));
tUserinfoService.insert(tUserinfo);
photo.transferTo(new File(path,filename));
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
@RequestMapping("/delete")
public String delete(String name){
tUserinfoService.deleteById(name);
return "redirect:/sysUser/findall?page=1&pageSize=5";
}
@RequestMapping("/toedit")
public String toedit(String name,ModelMap modelMap){
TUserinfo userByname = tUserinfoService.findUserByname(name);
modelMap.addAttribute("user",userByname);
return "sysUser_edit";
}
@Controller
@RequestMapping("/sysUser")
public class SysUsercontroller {
@Autowired
private TUserinfoService tUserinfoService;
@RequestMapping("/findall")
public String findall(Integer page,Integer pageSize,ModelMap modelMap){
List<TUserinfo> findall = tUserinfoService.findall(page,pageSize);
Integer count=tUserinfoService.count();
PageInfo<TUserinfo> pageInfo=new PageInfo<>(findall);
Page page1=new Page(pageSize,page,count);
modelMap.addAttribute("users",pageInfo);
modelMap.addAttribute("pages",page1);
return "sysUser";
}
@RequestMapping("/add")
public String add(HttpServletRequest request, MultipartFile photo, TUserinfo tUserinfo) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
System.out.println(path);
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
@Controller
@RequestMapping("/sysOrder")
public class SysOrderController {
@Autowired
private TMovieorderService tMovieorderService;
@RequestMapping("findAll")
public String findAll(Integer page, Integer pageSize, ModelMap modelMap) {
List<TMovieorder> tMovieorders = tMovieorderService.findAll(page, pageSize);
Integer count = tMovieorderService.count();
Page page1 = new Page();
page1.setPageSize(pageSize);
page1.setPage(page);
page1.setCount(count);
PageInfo<TMovieorder> pageInfo = new PageInfo<>(tMovieorders);
modelMap.addAttribute("pages", page1);
modelMap.addAttribute("orders", pageInfo);
return "sysorder";
}
@RequestMapping("/findSome")
public String findSome(ModelMap modelMap, Integer page, Integer pageSize, Integer orderid,String userName) {
List<TMovieorder> tMovieorders = tMovieorderService.findSome(page, pageSize, orderid,userName);
PageInfo<TMovieorder> pageInfo=new PageInfo<>(tMovieorders);
modelMap.addAttribute("orders", pageInfo);
return "sysorder";
}
@RequestMapping("/ticketing")
public String ticketing(Integer id) {
TMovieorder tMovieorder = new TMovieorder();
tMovieorder.setStatus(2);
tMovieorder.setOrderid(id);
@Controller
@RequestMapping("/sysMovies")
public class SysMoviesController {
@Autowired
private TMovieService tMovieService;
@Autowired
private TSortService tSortService;
@Autowired
private TScheduleService tScheduleService;
@Autowired
private TMoviehallService tMoviehallService;
@RequestMapping("/findAll")
public String findAll(Integer page,Integer pageSize,ModelMap modelMap){
List<TMovie> findall = tMovieService.findall(page, pageSize);
PageInfo<TMovie> pageInfo=new PageInfo<>(findall);
Integer count = tMovieService.findCount();
Page page1=new Page(pageSize,page,count);
List<TMoviehall> all = tMoviehallService.findAll(null);
modelMap.addAttribute("movies",pageInfo);
modelMap.addAttribute("pages",page1);
modelMap.addAttribute("halls",all);
return "sysmovie";
}
@RequestMapping("/delete")
public String delete(Integer id){
tMovieService.deleteById(id);
return "redirect:/sysMovies/findAll?page=1&pageSize=10";
}
@RequestMapping("/toAdd")
public String toAdd(ModelMap modelMap){
List<TSort> all = tSortService.findAll(null);
modelMap.addAttribute("sorts",all);
return "movie_add";
}
@RequestMapping("/add")
public String add(HttpServletRequest request,MultipartFile photo,TMovie tMovie) throws IOException {
String path = request.getSession().getServletContext().getRealPath("/");
path=path+"/static/image";
String filename=photo.getOriginalFilename();
String movieP="/static/image/"+filename;
tMovie.setMoviephoto(movieP);