struts2上传文件,怎么获取文件的后缀名
jsp代码
<input name="cmpPic" class="{validate:{required:true,accept:'bmp?|jpg|gif|png'}}" type="file"/> String path=ServletActionContext.getServletContext().getRealPath("/company_image"); File cmpPicSrc= new File(company.getCmpPic()); String newFileName=company.getCmpId()+"_"+System.currentTimeMillis()+".jpg"; File cmpPicDest= new File(path,newFileName); FileUtils.copyFile(cmpPicSrc, cmpPicDest);