java - 获取从 Thymeleaf 到控制器的文件路径
问题描述
我必须从 Excel 文件中获取一些数据,并且在尝试测试时我手动设置路径(它有效!)。
现在我想创建一个页面并使用按钮选择文件以获取路径。
这是我的控制器:
@RequestMapping(value = "/mypage")
public String fct(Model md) throws Exception{
File excel=new File("pathofmyfile/name.xls");//here the path
FileInputStream fis= new FileInputStream(excel);
HSSFWorkbook wb=new HSSFWorkbook(fis);
HSSFSheet ws=wb.getSheet("Feuil1");//to read first sheet only
int nbligne=ws.getLastRowNum()+1;//to get number of line not empty
String[] cotes=new String[nbligne];
for(int i =0;i<nbligne;i++) {
HSSFRow ligne= ws.getRow(i);
HSSFCell cell= ligne.getCell(0);
cotes[i]= cell.toString().substring(cell.toString().lastIndexOf("=") + 1);
System.out.println(cotes[i]);
}
return "mypage";
}
现在我想要你的建议或 html 页面的示例如何将 excel 的路径从 html 传递到控制器
解决方案
推荐阅读
- amazon-web-services - 如何在 Kubernetes 的 statefulSet 定义中使用现有的 PVC?
- regex - 为 ID 创建正则表达式验证器,例如“
- -ID” - go - 如何从这种类型的 json 响应中获取数据?
- python - 在 Python 中,有没有办法从 URL 中捕获以下 YYYYMMDD-N
- javascript - 接受带有组件的参数作为反应中的函数(快速修复)
- amazon-web-services - 用于限制同时登录的 Aws Lambda 身份验证后触发函数
- android - Android gradle 抱怨对象库有多个输出
- grpc - 发送大数据时我应该在 grpc 中压缩吗
- javascript - 如何防止 React 子组件重新渲染?
- google-apps-script - 如何使用 Apps 脚本在 Google 表格中记录历史数据