我有文件资源
FileResource curResource = new FileResource(new File(basepath +
"/WEB-INF/docs/"+path+".pdf"));
我想通过单击按钮从计算机上的浏览器保存此文件。我怎么能在 Vaadin 7 中做到这一点?谢谢
我尝试这样的事情:
ExternalResource resource = new ExternalResource(basepath +
"/WEB-INF/icons/"+"block_16.png");
Page.getCurrent().open(resource.getURL(),"Download",true);
但我的 about:blank 页面是空的,没有任何反应......
最佳答案
我解决了我的问题!
private String basepath = VaadinService.getCurrent()
.getBaseDirectory().getAbsolutePath();
private Button saveExcel = new Button();
Resource res = new FileResource(new File(basepath +
"/WEB-INF/docs/settings.xlsx"));
FileDownloader fd = new FileDownloader(res);
fd.extend(saveExcel);
在Vaadin中从服务器下载非常容易
关于java - Vaadin7 如何从服务器下载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15762991/