开发者

How to close socket when MaxUploadSizeExceededException occur?

I am developing upload system of image. I set maxUploadSize, using CommonsMultipartResolver. When i try to upload over max size image file, MaxUploadSizeExccededException occur. but all of image file is sent, although it has over 1G byte.

how to close socket? I want close socket when this exception occur.

thanks you.

controller.xml

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" >
        <property name="maxUploadSize" value="100" />
</bean>

controller.java

@RequestMapping(value="upload/", method={RequestMethod.POST})
public void uploadImage( ThumbnailRequestParams thumb开发者_StackOverflow社区nailRequestParams
                          , HttpServletResponse response) throws IOException{   
        uploadImage(thumbnailRequestParams, response);
} 

form.html

<form action="upload/" method="post" NAME="testForm" ENCTYPE="multipart/form-data">
    <input type="file" id="file" name="file"/><br/>
    idName : <input type="text" id="idName" name="idName"/><br/>
    <input type="submit" value="upload"/>
</form>


You should not throw an IOException but catch the MaxUploadSizeExceededExeception. In the catch block you can then close the socket.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜