同学好,其实同学可以站在业务的角度去理解,就清晰了。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中获取到店铺