基于WEB的网上购物系统-ssh源码

基于WEB的网上购物系统主要功能包括:前台用户登录退出、注册、在线购物、修改个人信息、后台商品管理等等。本系统结构如下:
(1)商品浏览模块:
        实现浏览最新商品
        实现按商品名称浏览商品
        实现根据商品分类浏览商品
(2)购物车:
        登录后可以将商品加入购物车,或从购物车移除商品
(3)登录、注册:
        购物前需要登录,如果没有账号则可以先注册
(4)提交、查询订单:
        商品加入购物车后可以提交订单,也可以查看自己的所有订单

  (5) 后台管理员模块
        用户登录功能:通过账号登录系统。
        商品分类管理功能:可以查询所有商品分类,添加新的商品分类,删除已有的分类
        商品管理功能:可以查询所有商品,添加新商品,删除已有商品
        订单管理功能:可以查询所有订单,对未发货的订单进行发货处理
        用户管理功能:可以查询所有用户,查询指定用户,删除用户
        修改登录密码功能:修改管理员的登录密码



项目访问路径:
  前台:http://localhost:8080/webShopping
  后台:http://localhost:8080/webShopping/admin/login.jsp

用户输入正确的信息后即可进入重新设置密码页面,进行秘密的重置。

找回密码关键代码如下:

public String findUser()

      {     String username= user.getUsername();

             String name= user.getName();

             String sex= user.getSex();

             String post= user.getPost();

             String address= user.getAddress();

             String phone= user.getPhone();

             String email= user.getEmail();

             User user=this.service.findUserByinfo(username, name,sex,phone, post, address, email);  //查询是否有该用户信息

             if(user==null){

                    ActionContext.getContext().put("findUsernull", "没有该用户信息!");

                    return "findUsernull";

             }else{

             ActionContext.getContext().getSession().put("findUser", user);

             return "findUser";

             }

用户登录关键代码如下:

public String login(){

             String username= user.getUsername();

             String password=user.getPassword();

             User user = service.getUserByLoginNameAndPassword(username,password);

//搜索是否存在该用户

             if(user == null){

                    ActionContext.getContext().put("message", "用户名或密码错误");          

                    return "login";

             }else{

                    ActionContext.getContext().getSession().put("user", user);

                    return "index";

             }

      }

商品添加到购物车关键代码如下:

public String execute() throws Exception {

             int commodityId= commodity.getCommodityId();

             Map session =(Map) ActionContext.getContext().getSession();

             Commodity commoditys = commodityService.findCommodityById (commodityId); //获得商品信息

             if(commoditys.getCommodityLeaveNum()==0){

                    ActionContext.getContext().getSession().put("comnull","商品已无货!");

                    return "error";

             }

             else{

             List<Commodity> car = null;        //声明一个购物车

             if(session.get("car") == null) {       //如果session中不存在购物车

                    car = new ArrayList<Commodity>();   //新建一个ArrayList实例

}

             else {

                    car = (List<Commodity>)session.get("car");  //取得购物车 }

                    }

commoditys.setCommodityLeaveNum(commoditys.getCommodityLeaveNum()-1);

                           commodityService.update(commoditys);

             session.put("car", car);//将购物车保存在session中

             return "success";        }


源码及原文链接:http://javadao.xyz/forum.php?mod=viewthread&tid=15

猜你喜欢

转载自www.cnblogs.com/javadao/p/11914942.html