老师好,我想问一下这个currentShop获取不到值是为什么,就光这几个视频我都反复对照了两遍了,没找到解决的方法,还请老师解答一下
来源:7-5 商品类别删除后端开发
慕丝5849131
2019-04-15
写回答
1回答
-
翔仔
2019-04-16
同学好,其实同学可以站在业务的角度去理解,就清晰了。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", "/myo2o/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; }
之后只要session还有效就能从session中获取到店铺
172020-02-25
相似问题