如何从MultipartHttpServletRequest对象获取文件的内容?对象、文件、内容、MultipartHttpServletRequest

2023-09-12 21:16:25 作者:青春无敌美少女

我想使用此策略网页上传的文件。即的Ajax文件上传教程。这是怎么回事都很好,但问题是在服务器端,在这里我想打开此文件并阅读其内容。 我使用下面的签名被称为在表格的提交方式。 即

I would like to upload a file from the web page using this strategy. i.e. Ajax file upload tutorial . It is going all fine, but the issue is on the server side, where I want to open this file and read its contents. I am using the following signature for the method which is called on the submit of the form. i.e.

公共@ResponseBody字符串的getFile(MultipartHttpServletRequest要求)

任何机构可以请让我知道,我怎么能提取该文件的内容是什么?

Can any body please let me know that how can I extract the contents of the file?

推荐答案

MultipartHttpServletRequest延伸MultipartRequest,其中有用于访问文件的方法。

MultipartHttpServletRequest extends MultipartRequest, which has methods for accessing the files.

您可以这样做:

MultipartFile file = request.getFile(paramName);

请参阅http://docs.spring.io/spring-framework/docs/3.2.0.M1/api/org/springframework/web/multipart/MultipartRequest.html

 
精彩推荐
图片推荐