2020-05-26 11:10
function sub0() {
        var formData = new FormData();
        formData.append("file",$("#filePath")[0].files[0]);
        // var type = $('#file_type').val()
        // var user = $('#file_user').val()
        formData.append("type","121212")
        formData.append("user","112121221")
        // console.log(fd.get("type"))
        // $("#myFormId").submit();
        $.ajax({
            // headers: {
            //     'Content-Type': 'multipart/form-data'
            // },
            url: "${base}/business/jsoupProduct/easypoiImport",
            data:  formData,
            type: "POST",
            dataType: "formData",
            //几个参数需要注意一下
            // type: "POST",//方法类型
            // dataType: "json",//预期服务器返回的数据类型
            [#--url: "${base}/business/jsoupProduct/easypoiImport",--]
            [#--data:formData,--]
            processData: false,
            contentType: false,
            // async:true,
            beforeSend:function(){
                index = layer.load();
            },
            success: function (result) {
                console.log(result);//打印服务端返回的数据(调试用)
                if(result.flag){
                    alert(result.data);
                    //return true;
                    //关闭加载层
                    layer.closeAll('loading');
                    window.location.reload();
                }else  {
                    //"报价失败的商品:"+
                    alert(result.data);
                    layer.closeAll('loading');
                    //return false;
                    window.location.reload();
                }
            },
            error : function() {
                alert("异常!");
            }
        });
    }
后台代码
  String type=getPara("type");
        Long productCategoryId = getParaToLong("productCategoryId"); //品目
        Long brandId = getParaToLong("brandId"); //品牌
        String pinpai=getPara("brandId");
        Map map1=getParaMap();
        UploadFile file = getFile();
        File file1 = file.getFile();
2020-05-26 11:08
@你妹啊 用getPara和getParaMap()都是空,浏览器上面可以看到FormData的参数,后台就是接收不到,弄了一上午了,这是bug吗
2020-05-07 21:12
@lyh061619 @lyh061619 可能不太一样,你这个是条状一个新页面,我的是在原来的页面,通过异步请求,在之前的页面追加视图页面。