NutzCN Logo
问答 fileUpload进行文件上传,TempFile为null
发布于 1806天前 作者 qq_256d0369 1454 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

参考imageUpload,使用uploadifive上传文件,@Param("Filedata") TempFile tf,。tf一直为null

@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
    @POST
    @At
    @Ok("json")
    public Object uploadPlaceFile(@Param("Filedata") TempFile tf, HttpServletRequest req, AdaptorErrorContext err,
                                  @Param("layerCode") String layerCode, @Param("oid") int oid, @Param("fileType")int fileType,@Param("the_files")String fileName){

        return Result.success("地名文件列表获取成功");

    }
function initFileUpload(){

    $('#placeFileUpload').uploadifive({
        'auto': false,
        'multi': false,
        'width': '98%',
        'height': '30',
        'buttonText': '请选择文件',
        'fileType': '*',
        'fileSizeLimit': 209715.2,
        'queueSizeLimit': 1,
        'fileObjName': 'the_files',
        'queueID': 'queuePlaceFile',
        'removeCompleted':true,
        'uploadScript': base+'/platform/stargis/place/uploadPlaceFile',
        'onUploadComplete': function (file, data) {

            getTablePlaceFileByHttp();

        },
        'onDrop': function (file, fileDropCount) {

            clearFile();
        },
        'onClearQueue': function (queue) {

            clearFile();
        },
        'onCancel': function () {

            clearFile();
        }
    });
}
$('#placeFileUpload').data('uploadifive').settings.formData = { "layerCode":layerCode,"oid":oid,"fileType":placeFileType};
    $('#placeFileUpload').uploadifive('upload');
[DEBUG] 2017-07-18 14:38:50,810 org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:184) - Select Html4 Form upload parser --> /platform/stargis/place/uploadPlaceFile
[DEBUG] 2017-07-18 14:38:50,817 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:39) - FastUpload : /platform/stargis/place/uploadPlaceFile
[DEBUG] 2017-07-18 14:38:50,821 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:54) - info created
[DEBUG] 2017-07-18 14:38:50,821 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:60) - Params map created - 0 params
[DEBUG] 2017-07-18 14:38:50,823 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:77) - boundary: 
-----------------------------12045300425902
[DEBUG] 2017-07-18 14:38:50,831 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:100) - skip first boundary
[DEBUG] 2017-07-18 14:38:50,831 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:111) - Reading...
[DEBUG] 2017-07-18 14:38:50,834 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[20170209161331.png],fieldName=[the_files]
[DEBUG] 2017-07-18 14:38:50,835 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137) - Upload Info: name=20170209161331.png,content_type=image/png
[DEBUG] 2017-07-18 14:38:50,884 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[layerCode]
[DEBUG] 2017-07-18 14:38:50,884 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[layerCode] value=[2001]
[DEBUG] 2017-07-18 14:38:50,884 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[oid]
[DEBUG] 2017-07-18 14:38:50,884 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[oid] value=[8156]
[DEBUG] 2017-07-18 14:38:50,885 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[fileType]
[DEBUG] 2017-07-18 14:38:50,885 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[fileType] value=[10]
[DEBUG] 2017-07-18 14:38:50,885 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:231) - ...Done 3175606 bytes readed
[DEBUG] 2017-07-18 14:39:10,128 cn.wizzer.app.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:26) - [POST]URI=/platform/stargis/place/uploadPlaceFile 19342ms
[WARN ] 2017-07-18 14:39:10,128 org.quartz.impl.jdbcjobstore.Job
2 回复

看这行日志, 文件的表单名称应该是the_files

[DEBUG] 2017-07-18 14:38:50,834 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[20170209161331.png],fieldName=[the_files]

所以,应该写成

@Param("the_files") TempFile tf

谢谢。看来还是对你原来的代码看的不够仔细

添加回复
请先登陆
回到顶部