0
봄 최대 절전 모드로 작업 중이며 Excel 파일을 가져 오려고합니다. Extension을 검사하여 아무도 Excel 이외의 파일을 업로드 할 수 없도록합니다. 즉, xls 또는 xlsx 확장명을 가진 파일로 가져 오기를 제한하십시오. 내 코드는 여기에 있습니다 :Excel 파일 가져 오기 java spring hibernate
public class ImportCandidatesFormController extends BNUAbstractFormController {
private ImportCandidatesBL importCandidatesBL;
private ExcelReader reader;
@Override
protected ModelAndView processFormSubmission(HttpServletRequest request,
HttpServletResponse response, Object command, BindException arg3)
throws Exception {
FileUploadVO vo = (FileUploadVO) command;
MultipartFile file = vo.getFile();
System.out.println("File Uploaded: " + file.getOriginalFilename());
boolean isSuccessful = importCandidatesBL.importAndSaveCandidates(
file.getInputStream(),
SessionUtil.getCurrentUser(request.getSession()));
return new ModelAndView(new RedirectView("importCandidates.do?s=1"));
}
public ImportCandidatesBL getImportCandidatesBL() {
return importCandidatesBL;
}
public void setImportCandidatesBL(ImportCandidatesBL importCandidatesBL) {
this.importCandidatesBL = importCandidatesBL;
}
}
그래서 질문은 무엇입니까? –
확장자가 xlsx인지 아닌지를 확인하는 코드가 필요합니다. ,,, 그렇지 않으면 업로드 할 것입니다. nothng가 발생합니다. 알고 싶다면 와트를 알고 있습니다. –