请稍等 ...
×

采纳答案成功!

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

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

插入代码

1回答

翔仔 2019-09-29 00:52:56

这个需要同学结合后端方法来看,后端对应的controller方法如下

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""/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;
    }

你的js里面第一个画框框的地方有可能获取不到shopId,即有可能再次访问这个页面的时候,可能没有传入shopId,那么传入后台的时候shopId取不到,则会执行 if shopId<=0的逻辑,从session去获取shopId,或者从让其跳转,如果从后台获取到,则设置shopId的值

0 回复 有任何疑惑可以回复我~
  • 提问者 慕用1382692 #1
    老师,如果第一次获得shopId=1成功,并存入currentShop,但是第二次shopId=2没有获得成功,去currentShop里去取,取到的是shopId=1,这是说明明是shopId=2,却获得的是1
    回复 有任何疑惑可以回复我~ 2019-09-29 05:06:19
  • 翔仔 回复 提问者 慕用1382692 #2
    是啊,这样也能防止店家A通过输入店家B的店铺id去获取店家B的店铺信息。。
    回复 有任何疑惑可以回复我~ 2019-09-29 11:39:16
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

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

帮助反馈 APP下载

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

公众号

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