简体   繁体   English

如何在Spring MVC框架中实现导入/导出文件功能

[英]How to implement import/export a file functionality in spring MVC framework

I am working on functionality where I have to import a csv file in my web application.I am using following code for this: 我正在研究必须在Web应用程序中导入csv文件的功能,为此我正在使用以下代码:

<input name="file1" type="file" id="fileid" />   
<input type="button" id="submit" value="Import File" onclick='importTestSet( document.getElementById("fileid").value)' />  

However the above code only returns the file name instead of the full path of the file.I searched on other forums and found that this is happening due to security reasons of the browser. 但是上面的代码只返回文件名而不是文件的完整路径。我在其他论坛上搜索后发现,由于浏览器的安全性原因,这种情况正在发生。

1) Is there any other way to get the full path of the file while importing 1)导入时是否还有其他方法可以获取文件的完整路径

2) Could you please help me with some sample code to implement this feature in spring MVC framework web application project. 2)能否请您提供一些示例代码来帮助我在Spring MVC框架Web应用程序项目中实现此功能。

您应该将该文件复制到临时文件夹中,以便当您可以在那时上传文件时,调用复制文件方法并将此方法放入输入标签<input type"file" onChange="copyFile()" />然后您必须到达这个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM