采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
老师,这个currentShop值为空,我回想了整个流程,实在是没想出来,老师在哪一步shopId的值设置成currentShop并丢进了session里面,希望老师指点一下
同学好,在拥有登录系统之后,就像下面的代码这样
private Map<String, Object> getShopManagementInfo(HttpServletRequest request) { Map<String, Object> modelMap = new HashMap<String, Object>(); long shopId = HttpServletRequestUtil.getLong(request, "shopId"); if (shopId <= 0) { Object currentShopObj = request.getSession().getAttribute("currentShop"); if (currentShopObj == null) { modelMap.put("redirect", true); modelMap.put("url", "/o2o/shopadmin/shoplist"); } else { Shop currentShop = (Shop) currentShopObj; modelMap.put("redirect", false); modelMap.put("shopId", currentShop.getShopId()); } } else { Shop currentShop = new Shop(); currentShop.setShopId(shopId); request.getSession().setAttribute("currentShop", currentShop); modelMap.put("redirect", false); } return modelMap; }
去赋值,视频会讲的,现阶段是硬编码,即指定一个固定的店铺,赋值到currentShop这个session的key里
非常感谢!
同学好,可以站在业务角度理解,我们这里有店家的店铺列表,然后session里面保存的是当前店铺,肯定是当他选择进入某个店铺的时候,给他从session里设置上。 然后一开始我们没有店铺列表的时候,是硬编码进去的,后面就在店铺列表点击进入某个店铺的时候设置
老师,这个currentShop为空值,怎么解决
登录后可查看更多问答,登录/注册
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
1.9k 47
1.8k 41
2.5k 40
1.8k 39
1.5k 37