本文主要是介绍Java项目:农资采购商城系统(java+SSM+JSP+JavaScript+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项目:是;
技术栈
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. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,前台地址:http://localhost:8080/snack/shop/index 注:tomcat中配置的路径必须为snack
用户账号/密码:wangzixiao/123456
后台地址:http://localhost:8080/snack/admin/login/adminLogin
管理员账号/密码:admin/123456
订单信息管理控制层:
@Controller
@RequestMapping("/orderInfo")
public class OrderInfoController {@Autowiredprivate IOrderInfoBiz orderInfoBiz;@RequestMapping("/addOrderInfo")@ResponseBodypublic Integer addOrderInfo(String ono, String odate, String ano, String price) {Integer in = 0;try {in = orderInfoBiz.addOrderInfo(ono, odate,ano,price);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}return in;}@RequestMapping("/getOrder")@ResponseBodypublic List<OrderInfo> getOrder(String mno) {return orderInfoBiz.getOrder(mno);}@RequestMapping("/getallOrder")@ResponseBodypublic List<OrderInfo> getallOrder(String mno) {return orderInfoBiz.getallOrder(mno);}@RequestMapping("/setStatus")@ResponseBodypublic Integer setStatus(String ono) {System.out.println("修改1");return orderInfoBiz.setStatus(ono);}@RequestMapping("/getOrderByPage")@ResponseBodypublic List<OrderInfo> getOrderByPage(String mno, Integer page) {return orderInfoBiz.getOrderByPage(mno,page);}@RequestMapping("/getPage")@ResponseBodypublic Integer getPage(String mno) {int total=orderInfoBiz.getTotal(mno);int page=total%2==0?total/2:total/2+1;return page;}
}
商品信息管理控制层:
@Controller
@RequestMapping("/goodsInfo")
public class GoodsInfoController {@Autowiredprivate IGoodsInfoBiz goodsInfoBiz;@RequestMapping("/findAll")@ResponseBodypublic List<GoodsInfo> findAll() { return goodsInfoBiz.findAll();}@RequestMapping("/find")@ResponseBodypublic GoodsInfo find(String str) {System.out.println(goodsInfoBiz.find(str));return goodsInfoBiz.find(str);}@RequestMapping("/findByTno")@ResponseBodypublic List<GoodsInfo> findByTno(String tno,String start) {return goodsInfoBiz.findByTno(tno,start);}@RequestMapping("/updateBal")@ResponseBodypublic Integer updateBal(String[] gnos,String[] nums) {return goodsInfoBiz.updateBal(gnos,nums);}@RequestMapping("/finds")@ResponseBodypublic List<GoodsInfo> finds() {return goodsInfoBiz.finds();}@RequestMapping("/upload")@ResponseBodypublic Map<String, Object> add(@RequestParam("upload")MultipartFile pic,HttpServletRequest request) {Map<String, Object> map = new HashMap<String, Object>();if(pic.isEmpty()){return map;}try{String savePath = "images/goods";String path = request.getServletContext().getRealPath("");String temp = request.getServletContext().getInitParameter("uploadPath");if(temp != null){savePath = temp;}//在用户上传的文件名的前面加上时间戳savePath += "/" + new Date().getTime() + "_" +pic.getOriginalFilename();File dest = new File(new File(path).getParentFile(),savePath);//将本地图片保存到服务器pic.transferTo(dest);map.put("fileName", pic.getOriginalFilename());map.put("uploaded", 1);map.put("url","../../../"+savePath);}catch(IllegalStateException e){e.printStackTrace();}catch(IOException e){e.printStackTrace();}return map;}//管理员端的商品信息@RequestMapping("/addGood")@ResponseBodypublic int addGood(@RequestParam Map<String,Object> map,@RequestParam MultipartFile pic, HttpServletRequest request){int result =-1;if(pic.isEmpty()){result=-2;//说明没有图片需要上传}String savePath="";try {String path= request.getServletContext().getRealPath("");String temp = request.getServletContext().getInitParameter("uploadpath");if(!StringUtil.checkNull(temp)){savePath = temp;}savePath="images/goods/"+pic.getOriginalFilename();File dest = new File(path, savePath);//将图片存到服务器的指定文件夹pic.transferTo(dest);} catch (IllegalStateException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}map.put("pics", savePath);result=goodsInfoBiz.addGood(map);return result;}@RequestMapping("/findgoods")@ResponseBodypublic List<GoodsInfo> findgoods() { return goodsInfoBiz.findgoods();}@RequestMapping("/del")@ResponseBodypublic int del(String gno) { return goodsInfoBiz.del(gno);}@RequestMapping("/getPage")@ResponseBodypublic Integer getPage(String tno) {int total=goodsInfoBiz.getTotal(tno);int page=total%10==0?total/10:total/10+1;return page;}
}
管理员信息控制层:
@Controller
@RequestMapping("/admin")
public class AdminInfoController {@Autowiredprivate IAdminInfoBiz adminInfoBiz;@RequestMapping("/checkLogin")@ResponseBodypublic Object checkLogin(HttpSession session) {Object obj = session.getAttribute("currentLoginUser");if(obj == null){return "{\"code\":\"101\"}";} else {return obj;}}@RequestMapping("/login")@ResponseBodypublic int login(String aname, String pwd, HttpSession session) { AdminInfo af = adminInfoBiz.login(aname, pwd);int result = 0;if(af != null){session.setAttribute("currentLoginUser", af);result = 1;}return result;}@RequestMapping("/success")public String loginSuccess(HttpSession session) { if(session.getAttribute("currentLoginUser") != null){return "/WEB-INF/back/page/index.html";} else {return "/bk/index.html";//以/开头从项目目录开始算}}@RequestMapping("/findAll")@ResponseBodypublic List<AdminInfo> findAll() { return adminInfoBiz.findAll();}@RequestMapping("/add")@ResponseBodypublic int add(String aname, String pwd, String tel) { return adminInfoBiz.add(aname,pwd,tel);}@RequestMapping("/update")@ResponseBodypublic int update(String aid,String tel) { return adminInfoBiz.update(aid,tel);}@RequestMapping("/del")@ResponseBodypublic int del(String aid) { return adminInfoBiz.del(aid);}/*@RequestMapping("/upload")@ResponseBodypublic Map<String, String> upload(MultipartFile pics, HttpServletRequest request, @RequestParam Map<String, Object> params) {if (pics.isEmpty()){return Collections.emptyMap();}String savePath = "../pics";try{String path = request.getServletContext().getRealPath("");String temp = request.getServletContext().getInitParameter("uploadpath");if(!StringUtil.checkNull(temp)){savePath = temp;}savePath += "/" + new Date().getTime() + "_" + new Random().nextInt(10000) + "-" + pics.getOriginalFilename();File dest = new File(path, savePath);//将图片存到服务器的指定文件pics.transferTo(dest);} catch (IllegalStateException e){e.printStackTrace();} catch (IOException e) {e.printStackTrace();}params.put("photo", savePath);if(adminInfoBiz.updatephoto(params) > 0){Map<String, String> map = new HashMap<String, String>();map.put("savepath", savePath);return map;} else {return Collections.emptyMap();}}*/
}
源码获取:俺的博客首页 "资源" 里下载!
这篇关于Java项目:农资采购商城系统(java+SSM+JSP+JavaScript+Mysql)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!