基于javaweb+mysql的ssm电影售票管理系统(java+ssm+jsp+jquery+ajax+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM电影售票管理系统(java+ssm+jsp+jquery+ajax+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版本; 6.是否Maven项目:否;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+jQuery+Ajax
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目, 前台运行地址:输入localhost:8080/ssm_zxdydp/index/index.action 登录 用户账号/密码: ls/lisi 后台运行地址:localhost:8080/ssm_zxdydp/admin/index.jsp 管理员账号/密码:admin/admin
| for (String ordersid : ids) { |
| this.ordersService.deleteOrders(ordersid); |
| } |
| return "redirect:/orders/getAllOrders.action"; |
| } |
| |
| |
| @RequestMapping("updateOrders.action") |
| public String updateOrders(Orders orders) { |
| this.ordersService.updateOrders(orders); |
| return "redirect:/orders/getAllOrders.action"; |
| } |
| |
| @RequestMapping("getAllOrders.action") |
| public String getAllOrders(String number) { |
| List<Orders> ordersList = this.ordersService.getAllOrders(); |
| PageHelper.getPage(ordersList, "orders", null, null, 10, number, this.getRequest(), null); |
| return "admin/listorders"; |
| } |
| |
| |
| @RequestMapping("queryOrdersByCond.action") |
| public String queryOrdersByCond(String cond, String name, String number) { |
| Orders orders = new Orders(); |
| if(cond != null){ |
| if ("ordercode".equals(cond)) { |
| orders.setOrdercode(name); |
| } |
| if ("usersid".equals(cond)) { |
| orders.setUsersid(name); |
| } |
| if ("total".equals(cond)) { |
| orders.setTotal(name); |
| } |
| if ("status".equals(cond)) { |
| orders.setStatus(name); |
| } |
| if ("addtime".equals(cond)) { |
| orders.setAddtime(name); |
| } |
| } |
| |
| List<String> nameList = new ArrayList<String>(); |
| List<String> valueList = new ArrayList<String>(); |
| nameList.add(cond); |
| valueList.add(name); |
| PageHelper.getPage(this.ordersService.getOrdersByLike(orders), "orders", nameList, valueList, 10, number, this.getRequest(), "query"); |
| name = null; |
| cond = null; |
复制
| } else { |
| buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>"); |
| } |
| buffer.append(" "); |
| if (maxPage <= (Integer.parseInt(number) + 1)) { |
| buffer.append("尾页"); |
| } else { |
| buffer.append("<a href=\"index/recommend.action?number=" + (maxPage - 1) + "\">尾页</a>"); |
| } |
| html = buffer.toString(); |
| this.getRequest().setAttribute("html", html); |
| this.getRequest().setAttribute("flimList", flimList); |
| return "users/list"; |
| } |
| |
| // 全部产品 |
| @RequestMapping("all.action") |
| public String all(String number) { |
| this.front(); |
| List<Film> flimList = new ArrayList<Film>(); |
| List<Film> tempList = this.filmService.getAllFilm(); |
| int pageNumber = tempList.size(); |
| int maxPage = pageNumber; |
| if (maxPage % 12 == 0) { |
| maxPage = maxPage / 12; |
| } else { |
| maxPage = maxPage / 12 + 1; |
| } |
| if (number == null) { |
| number = "0"; |
| } |
| int start = Integer.parseInt(number) * 12; |
| int over = (Integer.parseInt(number) + 1) * 12; |
| int count = pageNumber - over; |
| if (count <= 0) { |
| over = pageNumber; |
| } |
| for (int i = start; i < over; i++) { |
| Film x = tempList.get(i); |
| flimList.add(x); |
复制
| for (int i = start; i < over; i++) { |
| Film x = tempList.get(i); |
| flimList.add(x); |
| } |
| String html = ""; |
| StringBuffer buffer = new StringBuffer(); |
| buffer.append(" 共为"); |
| buffer.append(maxPage); |
| buffer.append("页 共有"); |
| buffer.append(pageNumber); |
| buffer.append("条 当前为第"); |
| buffer.append((Integer.parseInt(number) + 1)); |
| buffer.append("页 "); |
| if ((Integer.parseInt(number) + 1) == 1) { |
| buffer.append("首页"); |
| } else { |
| buffer.append("<a href=\"index/recommend.action?number=0\">首页</a>"); |
| } |
| buffer.append(" "); |
| if ((Integer.parseInt(number) + 1) == 1) { |
| buffer.append("上一页"); |
| } else { |
| buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>"); |
| } |
| buffer.append(" "); |
| if (maxPage <= (Integer.parseInt(number) + 1)) { |
| buffer.append("下一页"); |
| } else { |
| buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>"); |
| } |
| buffer.append(" "); |
| if (maxPage <= (Integer.parseInt(number) + 1)) { |
| buffer.append("尾页"); |
| } else { |
| buffer.append("<a href=\"index/recommend.action?number=" + (maxPage - 1) + "\">尾页</a>"); |
| } |
| html = buffer.toString(); |
| this.getRequest().setAttribute("html", html); |
| this.getRequest().setAttribute("flimList", flimList); |
| return "users/list"; |
| } |
| |
| // 全部产品 |
| @RequestMapping("all.action") |
| public String all(String number) { |
| this.front(); |
| List<Film> flimList = new ArrayList<Film>(); |
| List<Film> tempList = this.filmService.getAllFilm(); |
| int pageNumber = tempList.size(); |
| int maxPage = pageNumber; |
复制
| } else { |
| this.getRequest().setAttribute("message", "旧密码错误"); |
| } |
| return "admin/editpwd"; |
| } |
| |
| |
| @RequestMapping("exit.action") |
| public String exit() { |
| this.getSession().removeAttribute("adminid"); |
| this.getSession().removeAttribute("adminname"); |
| this.getSession().removeAttribute("realname"); |
| return "admin/index"; |
| } |
| |
| |
| @RequestMapping("createAdmin.action") |
| public String createAdmin() { |
| return "admin/addadmin"; |
| } |
| |
| |
| @RequestMapping("addAdmin.action") |
| public String addAdmin(Admin admin) { |
| admin.setAddtime(VeDate.getStringDateShort()); |
| this.adminService.insertAdmin(admin); |
| return "redirect:/admin/createAdmin.action"; |
| } |
| |
| |
| @RequestMapping("deleteAdmin.action") |
| public String deleteAdmin(String id) { |
| this.adminService.deleteAdmin(id); |
| return "redirect:/admin/getAllAdmin.action"; |
| } |
| |
| |
| @RequestMapping("deleteAdminByIds.action") |
| public String deleteAdminByIds() { |
| String[] ids = this.getRequest().getParameterValues("adminid"); |
| for (String adminid : ids) { |
| this.adminService.deleteAdmin(adminid); |
| } |
| return "redirect:/admin/getAllAdmin.action"; |
| } |
| |
复制
| cond = null; |
| return "admin/querycity"; |
| } |
| |
| |
| @RequestMapping("getCityById.action") |
| public String getCityById(String id) { |
| City city = this.cityService.getCityById(id); |
| this.getRequest().setAttribute("city", city); |
| return "admin/editcity"; |
| } |
| |
| public CityService getCityService() { |
| return cityService; |
| } |
| |
| public void setCityService(CityService cityService) { |
| this.cityService = cityService; |
| } |
| |
| } |
| |
| public class PageHelper { |
| |
| public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number, |
| HttpServletRequest request, String method) { |
| StringBuffer buffer = new StringBuffer(); |
| String name2 = name.substring(0, 1).toUpperCase() + name.substring(1); |
| String path = ""; |
| String action = "getAll" + name2 + ".action"; |
| if (method != null) { |
| action = "query" + name2 + "ByCond.action"; |
| } |
| |
| List<Object> objList = new ArrayList<Object>(); |
| if (nameList != null && valueList != null) { |
| for (int i = 0; i < nameList.size(); i++) { |
| path += "&" + nameList.get(i) + "=" + valueList.get(i); |
| } |
| } |
| int pageNumber = list.size(); |
| int maxPage = pageNumber; |
| if (maxPage % 10 == 0) { |
| maxPage = maxPage / 10; |
| } else { |
| maxPage = maxPage / 10 + 1; |
| } |
| if (number == null) { |
复制
| @Autowired |
| @Resource |
| private TopicService topicService; |
| @Autowired |
| @Resource |
| private UsersService usersService; |
| @Autowired |
| @Resource |
| private FilmService filmService; |
| |
| |
| @RequestMapping("createTopic.action") |
| public String createTopic() { |
| List<Users> usersList = this.usersService.getAllUsers(); |
| this.getRequest().setAttribute("usersList", usersList); |
| List<Film> filmList = this.filmService.getAllFilm(); |
| this.getRequest().setAttribute("filmList", filmList); |
| return "admin/addtopic"; |
| } |
| |
| @RequestMapping("addTopic.action") |
| public String addTopic(Topic topic) { |
| this.topicService.insertTopic(topic); |
| return "redirect:/topic/createTopic.action"; |
| } |
| |
| |
| @RequestMapping("deleteTopic.action") |
| public String deleteTopic(String id) { |
| this.topicService.deleteTopic(id); |
| return "redirect:/topic/getAllTopic.action"; |
| } |
| |
| |
| @RequestMapping("deleteTopicByIds.action") |
| public String deleteTopicByIds() { |
| String[] ids = this.getRequest().getParameterValues("topicid"); |
| for (String topicid : ids) { |
| this.topicService.deleteTopic(topicid); |
| } |
| return "redirect:/topic/getAllTopic.action"; |
| } |
| |
| |
| @RequestMapping("updateTopic.action") |
| public String updateTopic(Topic topic) { |
| this.topicService.updateTopic(topic); |
| return "redirect:/topic/getAllTopic.action"; |
| } |
| |
复制
| return "redirect:/index/preLogin.action"; |
| } else { |
| Users users = usersList.get(0); |
| if (password.equals(users.getPassword())) { |
| this.getSession().setAttribute("userid", users.getUsersid()); |
| this.getSession().setAttribute("username", users.getUsername()); |
| this.getSession().setAttribute("users", users); |
| return "redirect:/index/index.action"; |
| } else { |
| this.getSession().setAttribute("message", "密码错误"); |
| return "redirect:/index/preLogin.action"; |
| } |
| } |
| } |
| |
| |
| @RequestMapping("preReg.action") |
| public String preReg() { |
| this.front(); |
| return "users/register"; |
| } |
| |
| |
| @RequestMapping("register.action") |
| public String register(Users users) { |
| this.front(); |
| Users u = new Users(); |
| u.setUsername(users.getUsername()); |
| List<Users> usersList = this.usersService.getUsersByCond(u); |
| if (usersList.size() == 0) { |
| users.setRegdate(VeDate.getStringDateShort()); |
| this.usersService.insertUsers(users); |
| } else { |
| this.getSession().setAttribute("message", "用户名已存在"); |
| return "redirect:/index/preReg.action"; |
| } |
| |
| return "redirect:/index/preLogin.action"; |
| } |
| |
| |
| @RequestMapping("exit.action") |
复制
| |
| @RequestMapping("queryCityByCond.action") |
| public String queryCityByCond(String cond, String name, String number) { |
| City city = new City(); |
| if (cond != null) { |
| if ("cityname".equals(cond)) { |
| city.setCityname(name); |
| } |
| } |
| |
| List<String> nameList = new ArrayList<String>(); |
| List<String> valueList = new ArrayList<String>(); |
| nameList.add(cond); |
| valueList.add(name); |
| PageHelper.getPage(this.cityService.getCityByLike(city), "city", nameList, valueList, 10, number, this.getRequest(), "query"); |
| name = null; |
| cond = null; |
| return "admin/querycity"; |
| } |
| |
| |
| @RequestMapping("getCityById.action") |
| public String getCityById(String id) { |
| City city = this.cityService.getCityById(id); |
| this.getRequest().setAttribute("city", city); |
| return "admin/editcity"; |
| } |
| |
| public CityService getCityService() { |
| return cityService; |
| } |
| |
| public void setCityService(CityService cityService) { |
| this.cityService = cityService; |
| } |
| |
| } |
| |
复制
| return "redirect:/index/preLogin.action"; |
| } |
| return "users/usercenter"; |
| } |
| |
| @RequestMapping("userinfo.action") |
| public String userinfo() { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| String userid = (String) this.getSession().getAttribute("userid"); |
| this.getSession().setAttribute("users", this.usersService.getUsersById(userid)); |
| return "users/userinfo"; |
| } |
| |
| @RequestMapping("personal.action") |
| public String personal(Users users) { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| this.usersService.updateUsers(users); |
| return "redirect:/index/userinfo.action"; |
| } |
| |
| |
| @RequestMapping("addcart.action") |
| public String addcart() { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| String userid = (String) this.getSession().getAttribute("userid"); |
| Cart cart = new Cart(); |
| cart.setFilmid(getRequest().getParameter("goodsid")); |
| cart.setNum(getRequest().getParameter("num")); |
| cart.setPrice(getRequest().getParameter("price")); |
| cart.setUsersid(userid); |
| this.cartService.insertCart(cart); |
| return "redirect:/index/cart.action"; |
| } |
| |
| |
| @RequestMapping("cart.action") |
| public String cart() { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| String userid = (String) this.getSession().getAttribute("userid"); |
复制
| cart.setUsersid(userid); |
| List<Cart> cartList = this.cartService.getCartByCond(cart); |
| this.getRequest().setAttribute("cartList", cartList); |
| return "users/cart"; |
| } |
| |
| |
| @RequestMapping("deletecart.action") |
| public String deletecart(String id) { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| this.cartService.deleteCart(id); |
| return "redirect:/index/cart.action"; |
| } |
| |
| |
| @RequestMapping("preCheckout.action") |
| public String preCheckout() { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| String userid = (String) this.getSession().getAttribute("userid"); |
| Cart cart = new Cart(); |
| cart.setUsersid(userid); |
| List<Cart> cartList = this.cartService.getCartByCond(cart); |
| if (cartList.size() == 0) { |
| this.getSession().setAttribute("message", "请选购商品"); |
| return "redirect:/index/cart.action"; |
| } |
| List<City> cityList = this.cityService.getAllCity(); |
| this.getRequest().setAttribute("cityList", cityList); |
| return "users/checkout"; |
| } |
| |
| |
| @RequestMapping("checkout.action") |
| public String checkout() { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| String userid = (String) this.getSession().getAttribute("userid"); |
| Cart cart1 = new Cart(); |
复制
| |
| |
| @Controller |
| |
| @RequestMapping(value = "/cinema", produces = "text/plain;charset=utf-8") |
| public class CinemaAction extends BaseAction { |
| |
| @Autowired |
| @Resource |
| private CinemaService cinemaService; |
| @Autowired |
| @Resource |
| private CityService cityService; |
| |
| |
| @RequestMapping("createCinema.action") |
| public String createCinema() { |
| List<City> cityList = this.cityService.getAllCity(); |
| this.getRequest().setAttribute("cityList", cityList); |
| return "admin/addcinema"; |
| } |
| |
| |
| @RequestMapping("addCinema.action") |
| public String addCinema(Cinema cinema) { |
| this.cinemaService.insertCinema(cinema); |
| return "redirect:/cinema/createCinema.action"; |
| } |
| |
| |
| @RequestMapping("deleteCinema.action") |
| public String deleteCinema(String id) { |
| this.cinemaService.deleteCinema(id); |
| return "redirect:/cinema/getAllCinema.action"; |
| } |
| |
| |
| @RequestMapping("deleteCinemaByIds.action") |
| public String deleteCinemaByIds() { |
| String[] ids = this.getRequest().getParameterValues("cinemaid"); |
复制
| } |
| |
| |
| @Controller |
| |
| @RequestMapping(value = "/cinema", produces = "text/plain;charset=utf-8") |
| public class CinemaAction extends BaseAction { |
| |
| @Autowired |
| @Resource |
| private CinemaService cinemaService; |
| @Autowired |
| @Resource |
| private CityService cityService; |
| |
| |
| @RequestMapping("createCinema.action") |
| public String createCinema() { |
| List<City> cityList = this.cityService.getAllCity(); |
| this.getRequest().setAttribute("cityList", cityList); |
| return "admin/addcinema"; |
| } |
| |
| |
| @RequestMapping("addCinema.action") |
| public String addCinema(Cinema cinema) { |
| this.cinemaService.insertCinema(cinema); |
| return "redirect:/cinema/createCinema.action"; |
| } |
| |
| |
复制
| |
| |
| @Controller |
| |
| @RequestMapping(value = "/cart", produces = "text/plain;charset=utf-8") |
| public class CartAction extends BaseAction { |
| |
| @Autowired |
| @Resource |
| private CartService cartService; |
| @Autowired |
| @Resource |
| private UsersService usersService; |
| @Autowired |
| @Resource |
| private FilmService filmService; |
| |
| |
| @RequestMapping("createCart.action") |
| public String createCart() { |
| List<Users> usersList = this.usersService.getAllUsers(); |
| this.getRequest().setAttribute("usersList", usersList); |
| List<Film> filmList = this.filmService.getAllFilm(); |
| this.getRequest().setAttribute("filmList", filmList); |
| return "admin/addcart"; |
| } |
| |
| |
| @RequestMapping("addCart.action") |
| public String addCart(Cart cart) { |
| this.cartService.insertCart(cart); |
| return "redirect:/cart/createCart.action"; |
| } |
| |
| |
| @RequestMapping("deleteCart.action") |
| public String deleteCart(String id) { |
| this.cartService.deleteCart(id); |
| return "redirect:/cart/getAllCart.action"; |
| } |
| |
复制
| } |
| this.getRequest().setAttribute("id", id); |
| return "users/pay"; |
| } |
| |
| |
| @RequestMapping("pay.action") |
| public String pay(String id) { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id")); |
| orders.setStatus("已付款"); |
| this.ordersService.updateOrders(orders); |
| return "redirect:/index/showOrders.action"; |
| } |
| |
| |
| @RequestMapping("over.action") |
| public String over(String id) { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id")); |
| orders.setStatus("已收货"); |
| this.ordersService.updateOrders(orders); |
| return "redirect:/index/showOrders.action"; |
| } |
| |
| |
| @RequestMapping("cancel.action") |
| public String cancel(String id) { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
| Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id")); |
| orders.setStatus("已取消"); |
| this.ordersService.updateOrders(orders); |
| return "redirect:/index/showOrders.action"; |
| } |
| |
| |
| @RequestMapping("orderdetail.action") |
| public String orderdetail(String id) { |
| this.front(); |
| if (this.getSession().getAttribute("userid") == null) { |
| return "redirect:/index/preLogin.action"; |
| } |
复制
| |
| @RequestMapping(value = "/city", produces = "text/plain;charset=utf-8") |
| public class CityAction extends BaseAction { |
| |
| @Autowired |
| @Resource |
| private CityService cityService; |
| |
| |
| @RequestMapping("createCity.action") |
| public String createCity() { |
| return "admin/addcity"; |
| } |
| |
| |
| @RequestMapping("addCity.action") |
| public String addCity(City city) { |
| this.cityService.insertCity(city); |
| return "redirect:/city/createCity.action"; |
| } |
| |
| |
| @RequestMapping("deleteCity.action") |
| public String deleteCity(String id) { |
| this.cityService.deleteCity(id); |
| return "redirect:/city/getAllCity.action"; |
| } |
| |
| |
| @RequestMapping("deleteCityByIds.action") |
| public String deleteCityByIds() { |
| String[] ids = this.getRequest().getParameterValues("cityid"); |
| for (String cityid : ids) { |
| this.cityService.deleteCity(cityid); |
| } |
| return "redirect:/city/getAllCity.action"; |
| } |
| |
| |
| @RequestMapping("updateCity.action") |
| public String updateCity(City city) { |
| this.cityService.updateCity(city); |
| return "redirect:/city/getAllCity.action"; |
| } |
| |
| |
| @RequestMapping("getAllCity.action") |
| public String getAllCity(String number) { |
复制
| String userid = (String) this.getSession().getAttribute("userid"); |
| topic.setAddtime(VeDate.getStringDateShort()); |
| topic.setContents(this.getRequest().getParameter("contents")); |
| topic.setFilmid(this.getRequest().getParameter("goodsid")); |
| topic.setNum(this.getRequest().getParameter("num")); |
| topic.setUsersid(userid); |
| this.topicService.insertTopic(topic); |
| return "redirect:/index/detail.action?id=" + topic.getFilmid(); |
| } |
| |
| } |
| |
| |
| @Controller |
| |
| @RequestMapping(value = "/admin", produces = "text/plain;charset=utf-8") |
| public class AdminAction extends BaseAction { |
| |
| @Autowired |
| @Resource |
| private AdminService adminService; |
| |
| |
| @RequestMapping("login.action") |
| public String login() { |
| String username = this.getRequest().getParameter("username"); |
| String password = this.getRequest().getParameter("password"); |
| Admin adminEntity = new Admin(); |
| adminEntity.setUsername(username); |
| List<Admin> adminlist = this.adminService.getAdminByCond(adminEntity); |
| if (adminlist.size() == 0) { |
| this.getRequest().setAttribute("message", "用户名不存在"); |
| return "admin/index"; |
| } else { |
| Admin admin = adminlist.get(0); |
| if (password.equals(admin.getPassword())) { |
复制
| buffer.append("下一页"); |
| } else { |
| buffer.append("<a href=\"index/cate.action?number=" + (Integer.parseInt(number) + 1) + "&id=\" + id+ \"\">下一页</a>"); |
| } |
| buffer.append(" "); |
| if (maxPage <= (Integer.parseInt(number) + 1)) { |
| buffer.append("尾页"); |
| } else { |
| buffer.append("<a href=\"index/cate.action?number=" + (maxPage - 1) + "&id=\" + id+ \"\">尾页</a>"); |
| } |
| html = buffer.toString(); |
| this.getRequest().setAttribute("html", html); |
| this.getRequest().setAttribute("flimList", flimList); |
| return "users/list"; |
| } |
| |
| // 推荐产品 |
| @RequestMapping("recommend.action") |
| public String recommend(String number) { |
| this.front(); |
| Film goods = new Film(); |
| goods.setRecommend("是"); |
| List<Film> flimList = new ArrayList<Film>(); |
| List<Film> tempList = this.filmService.getFilmByCond(goods); |
| int pageNumber = tempList.size(); |
| int maxPage = pageNumber; |
| if (maxPage % 12 == 0) { |
| maxPage = maxPage / 12; |
| } else { |
| maxPage = maxPage / 12 + 1; |
| } |
| if (number == null) { |
| number = "0"; |
| } |
| int start = Integer.parseInt(number) * 12; |
| int over = (Integer.parseInt(number) + 1) * 12; |
| int count = pageNumber - over; |
| if (count <= 0) { |
| over = pageNumber; |
| } |
| for (int i = start; i < over; i++) { |
| Film x = tempList.get(i); |
| flimList.add(x); |
| } |
| String html = ""; |
复制
| HttpSession session = null; |
| try { |
| session = this.getRequest().getSession(); |
| } catch (Exception e) { |
| } |
| return session; |
| } |
| |
| |
| public void writeJsonResponse(String success) throws IOException, JSONException { |
| ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| HttpServletResponse response = attrs.getResponse(); |
| response.setContentType("text/json;charset=UTF-8"); |
| PrintWriter out = response.getWriter(); |
| |
| JSONObject json = new JSONObject(); |
| json.accumulate("result", success); |
| System.out.println(json.toString()); |
| out.println(json.toString()); |
| out.flush(); |
| out.close(); |
| } |
| } |
| |
| |
| @Controller |
| |
| @RequestMapping(value = "/ajax", produces = "text/plain;charset=utf-8") |
| public class AjaxAction extends BaseAction { |
| |
| @Autowired |
| @Resource |
| private CinemaService cinemaService; |
复制





