微信小程序开发,mvc能接受到请求,但是接受不到其他的属性?

微信小程序开发,mvc能接受到请求,但是接受不到其他的属性?

问题描述:

前端代码

 wx.uploadFile({
          url: app.globalData.url + "wxUploadImage.do",//请求地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",
            'accept': 'application/json'
          },
          formData: {
            'userId': app.globalData.user_login.data.workcode
          },
          success: function (res) {
            var data = res.data;
            data = JSON.parse(data);
            console.log(data.data);
            that.setData({
              isUploadFinish: true,
              imgUrl: tempFilePaths[0],
              uploadImgUrl:data.data
            });
            //do something
          }
        });

java代码

 @ResponseBody
    @RequestMapping("/wxUploadImage")
    public String upload(HttpServletRequest request, @RequestParam(value="file", required=false) MultipartFile file)  {
        Map<String, Object> dataMap = new HashMap<String, Object>();
        try {
            System.out.println("执行upload");
            request.setCharacterEncoding("UTF-8");
            String userId = request.getParameter("userId");
            System.out.println("userId="+userId);
            if(!file.isEmpty()) {
                String fileName = file.getOriginalFilename();
                String path = null;
                String type = null;
                type = fileName.indexOf(".") != -1 ? fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) : null;
                System.out.println(type);
                if (type != null) {
                    if ("GIF".equals(type.toUpperCase())||"PNG".equals(type.toUpperCase())||"JPG".equals(type.toUpperCase())) {
                        // 项目在容器中实际发布运行的根路径
                        String realPath = request.getSession().getServletContext().getRealPath("/");
                        // 自定义的文件名称
                        String trueFileName = String.valueOf(System.currentTimeMillis()) +"--"+userId+"."+ type;
                        // 设置存放图片文件的路径
                        path =  "/upload/signFault/" + trueFileName;
                        System.out.println("realPath==="+realPath);
                        file.transferTo(new File(realPath + path));
                        dataMap.put(DATA, path);
                        dataMap.put(RESPONSE, SUCCESS);
                        return JsonUtils.toJson(dataMap);
                    }else {
                        dataMap.put(RESPONSE, FAILURE);
                        dataMap.put(MSG, "请求异常");
                        return JsonUtils.toJson(dataMap);
                    }
                }else {
                    dataMap.put(RESPONSE, FAILURE);
                    dataMap.put(MSG, "请求异常");
                    return JsonUtils.toJson(dataMap);
                }
            }else {
                dataMap.put(RESPONSE, FAILURE);
                dataMap.put(MSG, "请求异常");
                return JsonUtils.toJson(dataMap);
            }
        } catch (Exception e) {
            e.printStackTrace();
            dataMap.put(RESPONSE, FAILURE);
            dataMap.put(MSG, "请求异常");
            return JsonUtils.toJson(dataMap);
        }

     }

后台接受不到那个userid,只显示执行了update 最主要的是测试服能用,正式服就拉稀了

是不是APP传来的时候没有值啊?