基于javaweb的婚纱影楼摄影商城系统(java+ssm+jsp+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的婚纱影楼摄影商城系统(java+SSM+JSP+jQuery+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+CSS+JavaScript+jQuery
使用说明
- 使用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
用户管理控制层:
//定义为控制器
@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 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 nameList = new ArrayList();
List valueList = new ArrayList();
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; }
后台管理员管理控制层:
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = “/admin”, produces = “text/plain;charset=utf-8”)
public class AdminAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private AdminService adminService;
// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
@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 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())) {
this.getSession().setAttribute(“adminid”, admin.getAdminid());
this.getSession().setAttribute(“adminname”, admin.getUsername());
this.getSession().setAttribute(“realname”, admin.getRealname());
} else {
this.getRequest().setAttribute(“message”, “密码错误”);
return “admin/index”;
return “admin/main”;
// 修改密码
@RequestMapping(“editpwd.action”)
public String editpwd() {
String adminid = (String) this.getSession().getAttribute(“adminid”);
String password = this.getRequest().getParameter(“password”);
String repassword = this.getRequest().getParameter(“repassword”);
Admin admin = this.adminService.getAdminById(adminid);
if (password.equals(admin.getPassword())) {
admin.setPassword(repassword);
this.adminService.updateAdmin(admin);
} 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”;
// 更新数据
@RequestMapping(“updateAdmin.action”)
public String updateAdmin(Admin admin) {
this.adminService.updateAdmin(admin);
return “redirect:/admin/getAllAdmin.action”;
// 显示全部数据
@RequestMapping(“getAllAdmin.action”)
public String getAllAdmin(String number) {
List adminList = this.adminService.getAllAdmin();
PageHelper.getPage(adminList, “admin”, null, null, 10, number, this.getRequest(), null);
return “admin/listadmin”;
// 按条件查询数据 (模糊查询)
@RequestMapping(“queryAdminByCond.action”)
public String queryAdminByCond(String cond, String name, String number) {
Admin admin = new Admin();
if (cond != null) {
if (“username”.equals(cond)) {
admin.setUsername(name);
if (“password”.equals(cond)) {
admin.setPassword(name);
if (“realname”.equals(cond)) {
admin.setRealname(name);
if (“contact”.equals(cond)) {
admin.setContact(name);
if (“addtime”.equals(cond)) {
admin.setAddtime(name);
List nameList = new ArrayList();
List valueList = new ArrayList();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.adminService.getAdminByLike(admin), “admin”, nameList, valueList, 10, number, this.getRequest(), “query”);
name = null;
cond = null;
return “admin/queryadmin”;
// 按主键查询数据
@RequestMapping(“getAdminById.action”)
public String getAdminById(String id) {
Admin admin = this.adminService.getAdminById(id);
this.getRequest().setAttribute(“admin”, admin);
return “admin/editadmin”;
public AdminService getAdminService() {
return adminService;
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
购物车管理控制层:
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = “/cart”, produces = “text/plain;charset=utf-8”)
public class CartAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private CartService cartService;
@Autowired
@Resource
private UsersService usersService;
@Autowired
@Resource
private JiancaiService jiancaiService;
// 准备添加数据
@RequestMapping(“createCart.action”)
public String createCart() {
List usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute(“usersList”, usersList);
List jiancaiList = this.jiancaiService.getAllJiancai();
this.getRequest().setAttribute(“jiancaiList”, jiancaiList);
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”;
// 批量删除数据
@RequestMapping(“deleteCartByIds.action”)
public String deleteCartByIds() {
String[] ids = this.getRequest().getParameterValues(“cartid”);
for (String cartid : ids) {
this.cartService.deleteCart(cartid);
return “redirect:/cart/getAllCart.action”;
// 更新数据
@RequestMapping(“updateCart.action”)
public String updateCart(Cart cart) {
this.cartService.updateCart(cart);
return “redirect:/cart/getAllCart.action”;
// 显示全部数据
@RequestMapping(“getAllCart.action”)
public String getAllCart(String number) {
List cartList = this.cartService.getAllCart();
PageHelper.getPage(cartList, “cart”, null, null, 10, number, this.getRequest(), null);
return “admin/listcart”;
// 按条件查询数据 (模糊查询)
@RequestMapping(“queryCartByCond.action”)
public String queryCartByCond(String cond, String name, String number) {
Cart cart = new Cart();
if (cond != null) {
if (“username”.equals(cond)) {
cart.setUsername(name);
if (“jiancainame”.equals(cond)) {
cart.setJiancainame(name);
if (“num”.equals(cond)) {
cart.setNum(name);
if (“price”.equals(cond)) {
cart.setPrice(name);
List nameList = new ArrayList();
List valueList = new ArrayList();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.cartService.getCartByLike(cart), “cart”, nameList, valueList, 10, number, this.getRequest(), “query”);
name = null;
cond = null;
return “admin/querycart”;
// 按主键查询数据
@RequestMapping(“getCartById.action”)
public String getCartById(String id) {
Cart cart = this.cartService.getCartById(id);
this.getRequest().setAttribute(“cart”, cart);
List usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute(“usersList”, usersList);
List jiancaiList = this.jiancaiService.getAllJiancai();
this.getRequest().setAttribute(“jiancaiList”, jiancaiList);
return “admin/editcart”;
public CartService getCartService() {
return cartService;
public void setCartService(CartService cartService) {
this.cartService = cartService;