上传在spring mvc下载xlsx文件

时间:2014-08-04 07:07:15

标签: java spring spring-mvc

我正在尝试上传xlsx文件并将其内容读入数据库。

我已完成下载xlsx但面临上传和阅读内容的问题

这是jsp:

<div align="center" style="margin-bottom: 10px;" >
                        <input style="width:200px" class="admin_search_btn" type=file name="uploadxls" value=""  />
                     </div>
                <div align="center" style="margin-bottom: 10px;" >  
                    <button type="submit" class="admin_search_btn">Submit</button>&nbsp;
                    <button type="submit" class="admin_search_btn">Cancel</button>
                </div>

我应该如何将此映射到控制器以在服务器上传文件并阅读它的内容?

2 个答案:

答案 0 :(得分:0)

文件上传与普通帖子(POST,GET)不同。如果您按照本教程Linkhere进行操作,您将看到错过的内容:

•表单标签,允许&#34; multipart&#34;交

<form method="POST" enctype="multipart/form-data" action="/upload">

•处理上传的servlet

请向我们提供您需要的更多详细信息。

答案 1 :(得分:0)

  

将文件上传到服务器:

this question's answer上已经回答了一个很好的解释,

在服务器上上传文件已经得到了解答。

  

使用java读取xlsx文件:

使用Apache-poi从文件中读取其内容.Apache POI是一个Java库,可以使用不同的Microsoft Office文件格式,如Excel,Power Point,Visio,MS Word等。

我发现this article非常有用,因为我也按照本文开始使用Apache-poi。

相关问题