请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Shop currentShop = (Shop)request.getSession().getAttribute("currentShop");

老师,这个currentShop值为空,我回想了整个流程,实在是没想出来,老师在哪一步shopId的值设置成currentShop并丢进了session里面,希望老师指点一下

正在回答

插入代码

2回答

同学好,在拥有登录系统之后,就像下面的代码这样

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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里

0 回复 有任何疑惑可以回复我~
翔仔 2019-07-04 20:32:31

同学好,可以站在业务角度理解,我们这里有店家的店铺列表,然后session里面保存的是当前店铺,肯定是当他选择进入某个店铺的时候,给他从session里设置上。 然后一开始我们没有店铺列表的时候,是硬编码进去的,后面就在店铺列表点击进入某个店铺的时候设置

0 回复 有任何疑惑可以回复我~
  • 提问者 weixin_慕村4009544 #1
    老师,这个currentShop为空值,怎么解决
    回复 有任何疑惑可以回复我~ 2019-07-04 23:51:42
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号