Java 在SpringMVC中上传下载xlsx文件

Java 在SpringMVC中上传下载xlsx文件,java,spring,spring-mvc,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="" />

我试图上传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>

我应该如何将此映射到控制器,以便在服务器上上载文件并读取其内容?

文件上载与正常的post、GET不同。如果您遵循本教程,您将看到您错过的内容:

•允许多部分post的表单标签

<form method="POST" enctype="multipart/form-data" action="/upload">
•处理上传的servlet

请给我们你需要的更多细节

将文件上载到服务器:

关于在服务器上上载文件的问题,已经在中给出了很好的解释

使用java读取xlsx文件:

使用Apache poi从文件中读取其内容。Apache poi是一个Java库,用于处理不同的Microsoft Office文件格式,如Excel、Power point、Visio、MS Word等


我发现这篇文章很有用,因为我也跟着这篇文章开始使用ApachePOI。

你能提供标签和还不能工作的控制器吗?@Markus:仍在测试代码谢谢,但它正在使用servlet,我正在SpringMVC中工作。