currentshop
来源:8-6 商品添加之前端实现下
我总是那么的乖
2020-03-11
从前台能接受到表单传过来的信息,但是到session的时候,
执行完这句shop.setShopId(currentShop.getShopId());后跳出一个页面
这句session是从shoplist中来的还是从哪?
是因为我没有从店铺进入,所以就没有session吗?
写回答
2回答
-
翔仔
2020-03-16
代码是这样的
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("shopId", shopId); modelMap.put("redirect", false); } return modelMap; }
就是说需要js把shopId传过来,否则就从session里面去获取。。所以看看同学js里面有没有传入?
http://localhost:8080/o2o/shopadmin/shopmanagement?shopId=1
00 -
翔仔
2020-03-12
是的,因为店铺和店家是一对多的关系,所以它不知道你到底选择的是哪个店铺。。如果为了测试的方便,可以直接给session写死一个
032020-03-15
相似问题