weixin_45138850
weixin_45138850
2019-09-24 10:52

SpringMVC+ajax上传文件+提交表单数据报错The current request is not a multipart request

  • spring
  • ajax

AJAX

var commercialName=$("#commercialName").val()
var commerciaPhone=$("#commerciaPhone").val()
var commerciaSite=$("#commerciaSite").val()
console.log(commercialName)
 var file=document.getElementById('file').files
var formData=new FormData()
formData.append("file",file[0])

    $.ajax({"url":"/systemController/merchantController/contact",
        "encType": 'multipart/form-data',
        "processData": false,
        "contentType":false,
        "data":{"file":formData,"commercialName":commercialName,"commerciaPhone":commerciaPhone,
            "commerciaSite":commerciaSite},
        "type":"post",
        "dataType":"json",
        "success":...
JAVA
``` @RequestMapping(value = "contact" ,method = RequestMethod.POST)
    @ResponseBody
    public Dto contact( MultipartFile file,
                       DbBusinessInformation businessInformation,
                       HttpServletRequest request)
也找了很多方法,还是没办法解决
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答