0

我是 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) {

有什么建议吗?

4

1 回答 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

于 2014-02-12T13:53:06.810 回答