赞
踩
作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目分为前后台,前台为普通用户登录,后台为管理员登录;
管理员角色包含以下功能:
管理员登录,管理员信息管理,查看用户信息,新闻公告管理,套餐类型信息管理,城市信息管理,拍摄基地信息管理,套餐商品信息管理,订单信息管理,评价信息管理等功能。
用户角色包含以下功能:
按分类查看,用户登录,查看商品详情,加入购物车,提交订单,查看订单,修改个人信息,查看网站公告,查看拍摄基地等功能。
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项目:否;
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
用户账号/密码: user/123456
管理员账号/密码:admin/admin
前台界面
后台界面
- package com.action;
- import java.util.ArrayList;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.beans.factory.annotation.Autowired;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.entity.Users;
- import com.service.UsersService;
- import com.util.PageHelper;
- import com.util.VeDate;
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/users" , produces = "text/plain;charset=utf-8")
- public class UsersAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private UsersService usersService;
-
- // 准备添加数据
- @RequestMapping("createUsers.action")
- public String createUsers() {
- return "admin/addusers";
- }
- // 添加数据
- @RequestMapping("addUsers.action")
- public String addUsers(Users users) {
- users.setRegdate(VeDate.getStringDateShort());
- this.usersService.insertUsers(users);
- return "redirect:/users/createUsers.action";
- }
-
- // 通过主键删除数据
- @RequestMapping("deleteUsers.action")
- public String deleteUsers(String id) {
- this.usersService.deleteUsers(id);
- return "redirect:/users/getAllUsers.action";
- }
-
- // 批量删除数据
- @RequestMapping("deleteUsersByIds.action")
- public String deleteUsersByIds() {
- String[] ids = this.getRequest().getParameterValues("usersid");
- for (String usersid : ids) {
- this.usersService.deleteUsers(usersid);
- }
- return "redirect:/users/getAllUsers.action";
- }
-
- // 更新数据
- @RequestMapping("updateUsers.action")
- public String updateUsers(Users users) {
- this.usersService.updateUsers(users);
- return "redirect:/users/getAllUsers.action";
- }
- // 显示全部数据
- @RequestMapping("getAllUsers.action")
- public String getAllUsers(String number) {
- List<Users> usersList = this.usersService.getAllUsers();
- PageHelper.getPage(usersList, "users", null, null, 10, number, this.getRequest(), null);
- return "admin/listusers";
- }
-
- // 按条件查询数据 (模糊查询)
- @RequestMapping("queryUsersByCond.action")
- public String queryUsersByCond(String cond, String name, String number) {
- Users users = new Users();
- if(cond != null){
- if ("username".equals(cond)) {
- users.setUsername(name);
- }
- if ("password".equals(cond)) {
- users.setPassword(name);
- }
- if ("realname".equals(cond)) {
- users.setRealname(name);
- }
- if ("sex".equals(cond)) {
- users.setSex(name);
- }
- if ("birthday".equals(cond)) {
- users.setBirthday(name);
- }
- if ("contact".equals(cond)) {
- users.setContact(name);
- }
- if ("regdate".equals(cond)) {
- users.setRegdate(name);
- }
- }
-
- List<String> nameList = new ArrayList<String>();
- List<String> valueList = new ArrayList<String>();
- nameList.add(cond);
- valueList.add(name);
- PageHelper.getPage(this.usersService.getUsersByLike(users), "users", nameList, valueList, 10, number, this.getRequest(), "query");
- name = null;
- cond = null;
- return "admin/queryusers";
- }
-
- // 按主键查询数据
- @RequestMapping("getUsersById.action")
- public String getUsersById(String id ) {
- Users users = this.usersService.getUsersById(id);
- this.getRequest().setAttribute("users", users);
- return "admin/editusers";
- }
-
- public UsersService getUsersService() { return usersService; }
-
- public void setUsersService(UsersService usersService) { this.usersService = usersService; }
-
- }
- package com.action;
-
- import java.io.File;
-
- import javax.servlet.http.HttpServletRequest;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.multipart.MultipartFile;
-
- import com.util.VeDate;
-
- @Controller
- @RequestMapping("/upload")
- public class UploadAction {
-
- @RequestMapping(value = "/image.action")
- public String upload(@RequestParam(value = "image", required = false) MultipartFile file,
- HttpServletRequest request, ModelMap model) {
- String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
- String fileName = file.getOriginalFilename();
- int i = fileName.lastIndexOf(".");
- String name = String.valueOf(VeDate.getStringDatex());
- String type = fileName.substring(i + 1);
- fileName = name + "." + type;
- File targetFile = new File(path, fileName);
- if (!targetFile.exists()) {
- targetFile.mkdirs();
- }
-
- // 保存
- try {
- file.transferTo(targetFile);
- } catch (Exception e) {
- e.printStackTrace();
- }
- model.addAttribute("imageFileName", fileName);
- return "saveimage";
- }
-
- @RequestMapping(value = "/files.action")
- public String files(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request,
- ModelMap model) {
- String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
- String fileName = file.getOriginalFilename();
- int i = fileName.lastIndexOf(".");
- String name = String.valueOf(VeDate.getStringDatex());
- String type = fileName.substring(i + 1);
- fileName = name + "." + type;
- File targetFile = new File(path, fileName);
- if (!targetFile.exists()) {
- targetFile.mkdirs();
- }
-
- // 保存
- try {
- file.transferTo(targetFile);
- } catch (Exception e) {
- e.printStackTrace();
- }
- model.addAttribute("imageFileName", fileName);
- return "savefile";
- }
- }
- package com.action;
- import java.util.ArrayList;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.beans.factory.annotation.Autowired;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.entity.Topic;
- import com.service.TopicService;
- import com.entity.Users;
- import com.entity.Jiancai;
- import com.service.UsersService;
- import com.service.JiancaiService;
- import com.util.PageHelper;
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/topic" , produces = "text/plain;charset=utf-8")
- public class TopicAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private TopicService topicService;
- @Autowired
- @Resource
- private UsersService usersService;
- @Autowired
- @Resource
- private JiancaiService jiancaiService;
-
- // 准备添加数据
- @RequestMapping("createTopic.action")
- public String createTopic() {
- List<Users> usersList = this.usersService.getAllUsers();
- this.getRequest().setAttribute("usersList", usersList);
- List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
- this.getRequest().setAttribute("jiancaiList", jiancaiList);
- 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";
- }
- // 显示全部数据
- @RequestMapping("getAllTopic.action")
- public String getAllTopic(String number) {
- List<Topic> topicList = this.topicService.getAllTopic();
- PageHelper.getPage(topicList, "topic", null, null, 10, number, this.getRequest(), null);
- return "admin/listtopic";
- }
-
- // 按条件查询数据 (模糊查询)
- @RequestMapping("queryTopicByCond.action")
- public String queryTopicByCond(String cond, String name, String number) {
- Topic topic = new Topic();
- if(cond != null){
- if ("username".equals(cond)) {
- topic.setUsername(name);
- }
- if ("jiancainame".equals(cond)) {
- topic.setJiancainame(name);
- }
- if ("num".equals(cond)) {
- topic.setNum(name);
- }
- if ("contents".equals(cond)) {
- topic.setContents(name);
- }
- if ("addtime".equals(cond)) {
- topic.setAddtime(name);
- }
- }
-
- List<String> nameList = new ArrayList<String>();
- List<String> valueList = new ArrayList<String>();
- nameList.add(cond);
- valueList.add(name);
- PageHelper.getPage(this.topicService.getTopicByLike(topic), "topic", nameList, valueList, 10, number, this.getRequest(), "query");
- name = null;
- cond = null;
- return "admin/querytopic";
- }
-
- // 按主键查询数据
- @RequestMapping("getTopicById.action")
- public String getTopicById(String id ) {
- Topic topic = this.topicService.getTopicById(id);
- this.getRequest().setAttribute("topic", topic);
- List<Users> usersList = this.usersService.getAllUsers();
- this.getRequest().setAttribute("usersList", usersList);
- List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
- this.getRequest().setAttribute("jiancaiList", jiancaiList);
- return "admin/edittopic";
- }
-
- public TopicService getTopicService() { return topicService; }
-
- public void setTopicService(TopicService topicService) { this.topicService = topicService; }
-
- }
- package com.action;
- import java.util.ArrayList;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.beans.factory.annotation.Autowired;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.entity.Orders;
- import com.service.OrdersService;
- import com.entity.Users;
- import com.service.UsersService;
- import com.util.PageHelper;
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/orders" , produces = "text/plain;charset=utf-8")
- public class OrdersAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private OrdersService ordersService;
- @Autowired
- @Resource
- private UsersService usersService;
-
- // 准备添加数据
- @RequestMapping("createOrders.action")
- public String createOrders() {
- List<Users> usersList = this.usersService.getAllUsers();
- this.getRequest().setAttribute("usersList", usersList);
- return "admin/addorders";
- }
- // 添加数据
- @RequestMapping("addOrders.action")
- public String addOrders(Orders orders) {
- this.ordersService.insertOrders(orders);
- return "redirect:/orders/createOrders.action";
- }
-
- // 通过主键删除数据
- @RequestMapping("deleteOrders.action")
- public String deleteOrders(String id) {
- this.ordersService.deleteOrders(id);
- return "redirect:/orders/getAllOrders.action";
- }
-
- // 批量删除数据
- @RequestMapping("deleteOrdersByIds.action")
- public String deleteOrdersByIds() {
- String[] ids = this.getRequest().getParameterValues("ordersid");
- 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 ("username".equals(cond)) {
- orders.setUsername(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;
- return "admin/queryorders";
- }
-
- // 按主键查询数据
- @RequestMapping("getOrdersById.action")
- public String getOrdersById(String id ) {
- Orders orders = this.ordersService.getOrdersById(id);
- this.getRequest().setAttribute("orders", orders);
- List<Users> usersList = this.usersService.getAllUsers();
- this.getRequest().setAttribute("usersList", usersList);
- return "admin/editorders";
- }
-
- public OrdersService getOrdersService() { return ordersService; }
-
- public void setOrdersService(OrdersService ordersService) { this.ordersService = ordersService; }
-
- }
如果也想学习本系统,下面领取。回复:190ssm
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。