欢迎使用CSDN-markdown编辑器
来源:互联网 发布:港式车仔面图片淘宝 编辑:程序博客网 时间:2024/06/08 13:06
今天练了一下excel的上传及获取数据,需要对文件类型进行判断,所以需要获取文件的后缀名,方法如下:
public class UploadFile extends ActionSupport{ private File excelfile; //获取上传的excel文件 private String excelfileFileName; //获取文件名 private String excelfileContentType; // private List<Excel> list;// private String excelfileContentType; public File getExcelfile() { return excelfile; } public void setExcelfile(File excelfile) { this.excelfile = excelfile; }// public String getExcelfileContentType() {// return excelfileContentType;// }//// public void setExcelfileContentType(String excelfileContentType) {// this.excelfileContentType = excelfileContentType;// } @Override public String execute() throws Exception { // TODO Auto-generated method stub System.out.println("zzx "+excelfile); System.out.println("zzx"+excelfileContentType); System.out.println(*****excelfileFileName.substring(excelfileFileName.lastIndexOf(".")+1)*****); //此处即可获得文件名的后缀 System.out.println("zzx"+excelfileFileName); list=new JxlReadExcel().main(excelfile); if(list==null){ System.out.println("有错"); return ERROR; } new ExcelDao().add(list); return SUCCESS; } public String getExcelfileFileName() { return excelfileFileName; } public void setExcelfileFileName(String excelfileFileName) { this.excelfileFileName = excelfileFileName; } public List<Excel> getList() { return list; } public void setList(List<Excel> list) { this.list = list; } public String getExcelfileContentType() { return excelfileContentType; } public void setExcelfileContentType(String excelfileContentType) { this.excelfileContentType = excelfileContentType; }}
0 0
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- python代码缩进
- MySql zip Package installed on Windows 7
- 【BZOJ】1087 互不侵犯King
- Gson中fromJson方法的返回值
- Android switch当代码setCheck时,不调用onCheckedChanged
- 欢迎使用CSDN-markdown编辑器
- linux内存管理之物理内存相关知识
- 欢迎使用CSDN-markdown编辑器
- HDU杭电 1039 Easier Done Than Said?(字符串问题)
- Ubuntu 下安装 octave 4.0
- 依赖项属性概述 wpf
- wxhl ios bj 49 张浩 学习心得连载 第二章
- Linux下php5.3.6的安装:checking whether libxml build works... no
- 【BZOJ】1213 高精度开根