在JQuery文件上传器中获取异常

问题描述 投票:0回答:1

我是JQuery文件上传器的新手,我正在实现其中的一部分。当我从JQuery文件上传器中选择一个图像时,调用将转到服务器端(SpringController),但API返回:

406不可接受

这是我对服务器的调用:

$(this).fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: uploadSettings.upload_url,
        type: 'POST',
        maxNumberOfFiles: uploadSettings.maxNumberOfFiles,
        maxFileSize: uploadSettings.maxFileSize,
        acceptFileTypes: uploadSettings.fileSelection,
        sequentialUploads: true,
        paramName:'uploadfiles[]',
        dataType: 'text'
    });

我的Java控制器代码如下:

@RequestMapping(value = { "/user/fileuploader" }, method = RequestMethod.POST, 
produces = "text/plain")


@ResponseBody public String uploadFileHandler(
@RequestParam("uploadfiles[]") MultipartFile[] file,
HttpServletRequest request, HttpServletResponse response) {

有什么建议?

java jquery file-upload jquery-file-upload jhipster
1个回答
0
投票

这是一个使用与JHipster非常相似的堆栈的项目(我是两个项目的作者),并使用相同的JQuery插件上传:

https://github.com/ippontech/tatami/blob/master/src/main/java/fr/ippon/tatami/web/fileupload/FileController.java#L193

如你所见,我的回归对象是不同的。您可以复制我的代码:

https://github.com/ippontech/tatami/tree/master/src/main/java/fr/ippon/tatami/web/fileupload

© www.soinside.com 2019 - 2024. All rights reserved.