请稍等 ...
×

采纳答案成功!

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

正在回答 回答被采纳积分+3

插入代码

1回答

翔仔 2019-04-29 00:15:27

同学好,其实同学站在业务的角度来理解,就比较容易理解了,这里你创建了多个店铺后,在shoplist的页面选择其中一个店铺,就会来到这个店铺的管理控制台,那么选择店铺的时候,咱们就会把currentShop给设置到session里,后面就直接从session取就好了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@RequestMapping(value = "/getshopmanagementinfo", method = RequestMethod.GET)
    @ResponseBody
    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;
    }


3 回复 有任何疑惑可以回复我~
  • 提问者 Firenze_ #1
    感谢老师的回答,我想问的就是这个地方,之前在哪个环节有set过这个currentshop吗??,好像没有看过
    回复 有任何疑惑可以回复我~ 2019-04-30 09:00:06
  • 翔仔 回复 提问者 Firenze_ #2
    有呢,一开始我们先是硬编码 后来就在shoplist里面设置这个session,也许在后面 都会有交代的
    回复 有任何疑惑可以回复我~ 2019-05-01 00:28:20
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

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

帮助反馈 APP下载

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

公众号

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