我得到 Validation.EncodingRequired 用于使用 struts 框架上传 xls/xlsx 文件代码
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
FileUploadForm uploadForm = (FileUploadForm) form;
FileOutputStream outputStream = null;
FormFile formFile = null;
try {
formFile = uploadForm.getFile();
String path = getServlet().getServletContext().getRealPath("")+"/"+
formFile.getFileName();
outputStream = new FileOutputStream(new File(path));
outputStream.write(formFile.getFileData());
}
finally {
if (outputStream != null) {
outputStream.close();
}
}
uploadForm.setMessage("The file "+formFile.getFileName()+" is uploaded successfully.");
return mapping.findForward(SUCCESS);
}
Validation.EncodingRequired 问题已上线 -
outputStream.write(formFile.getFileData());
我怎样才能解决这个问题?