基于javaweb+mysql的jsp+servlet图书商城管理系统(java+servlet+jsp+jdbc+tomcat+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet图书商城管理系统(java+servlet+jsp+jdbc+tomcat+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、8.0等版本均可; 6.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目;
技术栈
Servlet、JSP、JDBC、MySQL5.7/8.0、Tomcat8等
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目; 3. 将项目中util/SimpleDataSource.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/jsp_tushushop/ 登录 用户账号/密码:user/123456 管理员账号/密码:admin/admin
Map<Object,Object> map=new HashMap<Object, Object>();
map.put("uId",request.getSession().getAttribute("frontuserId"));
map.put("pageStart",start);
map.put("pageSize",length);
PageHelp<Account> pageHelp= userService.selectAccountLimit(map);
DataTables datatable=new DataTables();
datatable.setData(pageHelp.getList());
datatable.setRecordsFiltered(pageHelp.getRecord());
datatable.setRecordsTotal(pageHelp.getRecord());
return datatable;
//获得金额
@RequestMapping("getMoneyAcount")
@ResponseBody
public Object getMoneyAcount(HttpServletRequest request){
@RequestMapping("selectUserOne")
@ResponseBody
public AjaxResult getUserOne(Userinfo userinfo){
AjaxResult aj=new AjaxResult();
Userinfo rs = userService.selectUserOne(userinfo);
aj.setTag(rs);
return aj;
//注册
@RequestMapping("addUserRegister")
@ResponseBody
public AjaxResult addUserOne(Userinfo userinfo){
@Autowired
public shopService shopService=null;
@Autowired
public typeService typeService;
//主页
@RequestMapping("index")
public String gotoIndex(HttpServletRequest request){
List<Snackinfo> HotSnackList = shopService.getHotSnack();
List<Snackinfo> newSnackList = shopService.getNewSnack();
List<Type> typeList = typeService.getall();
@ResponseBody
public DataTables userAccountLimit(HttpServletRequest request,int start,int length){
Map<Object,Object> map=new HashMap<Object, Object>();
map.put("uId",request.getSession().getAttribute("frontuserId"));
map.put("pageStart",start);
map.put("pageSize",length);
PageHelp<Account> pageHelp= userService.selectAccountLimit(map);
DataTables datatable=new DataTables();
datatable.setData(pageHelp.getList());
datatable.setRecordsFiltered(pageHelp.getRecord());
datatable.setRecordsTotal(pageHelp.getRecord());
return datatable;
Double selectOrderdetailPayMoney = sorderService.selectOrderdetailPayMoney(oId);
dpm.setPayMoney(selectOrderdetailPayMoney.toString());
dpm.setuMoney(selectUserinfoMoney.getuMoney());
return ResponseUtil.successToClient(dpm);
//确认付款
@RequestMapping("userOrderPayMoneyConfirm")
@ResponseBody
public String userOrderPayMoneyConfirm(HttpServletRequest request,Float payNumber,Float uMoney,String uPasword,String oId){
Userinfo userinfo = (Userinfo)request.getSession().getAttribute("exituser");
if(userinfo.getuPassword().equals(uPasword)){
sorderService.updateOrderByoId(oId);
userService.updateUserinfoBypay(userinfo.getuId(), uMoney-payNumber);
return "admin/adminLogin";
//登录Main
@RequestMapping("adminGoMain")
public String adminLogin(HttpServletRequest request){
List<Type> typeList = typeService.getall();
request.setAttribute("adminMenu",adminLoginService.selectAllAdminMenu());
request.setAttribute("adminMenuChild",adminLoginService.selectAllAdminMenuChild());
request.getSession().setAttribute("type",typeList);
return "admin/adminMain";
//退出
@RequestMapping("adminMainToLoginOut")
@Autowired
private userService userService;
@Autowired
private sorderService sorderService;
@Autowired
private adminOrderService adminOrderService;
//跳转注册
@RequestMapping("userRegisterGet")
public String gotoRegister(){
return "user/register";
//注册判断用户名存在
@RequestMapping("selectUserOne")
@ResponseBody
//跳转订单页面
@RequestMapping("userGoOrder")
public String userGoOrder(HttpSession session){
return "user/myOrder";
//跳转历史订单
@RequestMapping("userGoSuccessOrder")
public String userGoSuccessOrder(){
return "user/myOrderSuccess";
//查看当前订单
@RequestMapping("userSucOrderLimit")
if(typeNum==0){
eId = (int)request.getSession().getAttribute("adminId");
}else{
eId=0;
return ResponseUtil.successToClient(userService.upDateByorderConfirm(id,typeNum,eId));
//去付款
@RequestMapping("userOrderPayMoney")
@ResponseBody
public String userOrderPayMoney(HttpServletRequest request,String oId){
DoPayMoney dpm=new DoPayMoney();
Userinfo selectUserinfoMoney = userService.selectUserinfoMoney((int)request.getSession().getAttribute("frontuserId"));
//跳转历史订单
@RequestMapping("userGoSuccessOrder")
public String userGoSuccessOrder(){
return "user/myOrderSuccess";
//查看当前订单
@RequestMapping("userSucOrderLimit")
@ResponseBody
public DataTables userSucOrderLimit(HttpServletRequest request,int start,int length){
Map<Object,Object> map=new HashMap<Object, Object>();
map.put("uId",request.getSession().getAttribute("frontuserId"));
Double selectOrderdetailPayMoney = sorderService.selectOrderdetailPayMoney(oId);
dpm.setPayMoney(selectOrderdetailPayMoney.toString());
dpm.setuMoney(selectUserinfoMoney.getuMoney());
return ResponseUtil.successToClient(dpm);
//确认付款
@RequestMapping("userOrderPayMoneyConfirm")
@ResponseBody
public String userOrderPayMoneyConfirm(HttpServletRequest request,Float payNumber,Float uMoney,String uPasword,String oId){
Userinfo userinfo = (Userinfo)request.getSession().getAttribute("exituser");
if(userinfo.getuPassword().equals(uPasword)){
sorderService.updateOrderByoId(oId);
public typeService typeService;
//主页
@RequestMapping("index")
public String gotoIndex(HttpServletRequest request){
List<Snackinfo> HotSnackList = shopService.getHotSnack();
List<Snackinfo> newSnackList = shopService.getNewSnack();
List<Type> typeList = typeService.getall();
request.setAttribute("HotSnackList",HotSnackList);
request.setAttribute("newSnackList",newSnackList);
request.getSession().setAttribute("type", typeList);
System.out.println("00");
return "user/index";
//注册判断用户名存在
@RequestMapping("selectUserOne")
@ResponseBody
public AjaxResult getUserOne(Userinfo userinfo){
AjaxResult aj=new AjaxResult();
Userinfo rs = userService.selectUserOne(userinfo);
aj.setTag(rs);
return aj;
//注册
@RequestMapping("addUserRegister")
@ResponseBody
public AjaxResult addUserOne(Userinfo userinfo){
AjaxResult aj=new AjaxResult();
System.out.println("存储过程相加:"+accountMapper.selectNum(4, 6));
return "admin/adminLogin";
//登录
@RequestMapping("adminGoLogin")
public String adminGoLogin(HttpServletRequest request,Admin admin){
List<Admin> adminSelect = adminLoginService.adminLogin(admin);
if(adminSelect.size()==1){
request.getSession().setAttribute("adminName", adminSelect.get(0).getAdUsername());
request.getSession().setAttribute("adminId", adminSelect.get(0).getAdId());
List<Permission> allPer = adminLoginService.selectAllPermission();
List<Permission> userPer = adminLoginService.selectRolePermission(adminSelect.get(0).getRoleId());
return aj;
//修改个人信息
@RequestMapping("editUserinfo")
@ResponseBody
public int editUserinfo(Userinfo userinfo){
int rs= userService.updateUserinfoById(userinfo);
return rs;
//跳转注册
@RequestMapping("userPersonalInfo")
public String gotoPersonalInfo(){
return "user/personalInfo";
//加载个人信息界面
@RequestMapping("userInfo")
PageHelp<DoSnack> pageHelp = shopService.selectOrderSnack(map);
DataTables datatable=new DataTables();
datatable.setData(pageHelp.getList());
datatable.setRecordsFiltered(pageHelp.getRecord());
datatable.setRecordsTotal(pageHelp.getRecord());
return datatable;
//type页面
@RequestMapping("puffingType")
public String puffing(HttpServletRequest request,DoSnackType doSnackType){
List<Snackinfo> TypeSnackList=shopService.selectPuffing(doSnackType.getType(),doSnackType.getSnackName());
Type type = typeService.getOne(doSnackType.getType());
request.setAttribute("TypeSnackTitle",type.getName());
request.setAttribute("TypeNum",doSnackType.getType());
@RequestMapping("userSucOrderLimit")
@ResponseBody
public DataTables userSucOrderLimit(HttpServletRequest request,int start,int length){
Map<Object,Object> map=new HashMap<Object, Object>();
map.put("uId",request.getSession().getAttribute("frontuserId"));
map.put("pageStart",start);
map.put("pageSize",length);
PageHelp<DoMyOrder> pageHelp= userService.selectMySuccessOrderLimit(map);
DataTables datatable=new DataTables();
datatable.setData(pageHelp.getList());
datatable.setRecordsFiltered(pageHelp.getRecord());
datatable.setRecordsTotal(pageHelp.getRecord());
return datatable;
//请确认收货
//查登陆的用户
@RequestMapping("readUserinfo")
@ResponseBody
public AjaxResult readUserinfo(Userinfo userinfo,HttpServletRequest request){
AjaxResult aj=new AjaxResult();
Userinfo usr= userService.selectUserinfoById(userinfo);
if(usr!=null){
aj.setTag(usr);
return aj;
//修改个人信息
@RequestMapping("editUserinfo")
@ResponseBody
public int editUserinfo(Userinfo userinfo){