AJAX提交数据时,参数与file一同提交

提交数据时,参数与file一同提交
1、ajax
url:A_Url,
contentType: false,
processData: false,
mimeType: "multipart/form-data",
type:"POST",

data:formData

 

2、data
var formData = new FormData();
formData.append('file', imageFile);
formData.append("json",JSON.stringify(jsondata));

 

3、Controller

    @RequestMapping(value="xx",method = RequestMethod.POST)
    @ResponseBody
    public Tip xx(MultipartFile file, HttpServletRequest request){
        String json = request.getParameter("json");
        if(json==null || json.length()==0){
            return ("无效参数");
        }
        JSONObject json = JSONObject.parseObject(postdata);
        return service.select(file,json);
    }

你可能感兴趣的:(JAVA,javascript)