取消文件上载时捕获异常?

时间:2013-10-01 21:40:25

标签: java spring servlets grails grails-2.0

我有一个上传表单,用户可以上传文件。当用户提交表单时,他可以取消请求:

    // abort old ajax request
    if(xhrObject && xhrObject.readyState != 4){
        xhrObject.abort();
    }   

当请求被取消时,服务器会抛出以下错误:

ERROR [/test].[default]  - Servlet.service() for servlet [default] in context with path [/test] threw exception
Message: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
    Line | Method
->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket
->>  371 | parseRequest in org.apache.commons.fileupload.FileUploadBase
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    126 | parseRequest in org.apache.commons.fileupload.servlet.ServletFileUpload
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by EOFException: Unexpected EOF read on the socket
->>  976 | makeAvailable in org.apache.commons.fileupload.MultipartStream$ItemInputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    886 | read      in     ''
|    101 | read . .  in java.io.InputStream
|     96 | copy      in org.apache.commons.fileupload.util.Streams
|     66 | copy . .  in     ''
|    366 | parseRequest in org.apache.commons.fileupload.FileUploadBase
|    126 | parseRequest in org.apache.commons.fileupload.servlet.ServletFileUpload
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread

我试图在我的控制器中捕获此错误:

def save() {
try {
...
} catch (Exception ex) {...}
}

事实证明这不起作用。

如何在我的操作中捕获已取消的上传内容?

0 个答案:

没有答案
相关问题