public FileRender(File file) { if (file == null) { throw new IllegalArgumentException("file can not be null."); } this.file = file; init(); }
public FileRender(File file, String downloadFileName) { this(file);
if (StrKit.isBlank(downloadFileName)) { throw new IllegalArgumentException("downloadFileName can not be blank."); } this.downloadFileName = downloadFileName; init(); }
public FileRender(String fileName) { if (StrKit.isBlank(fileName)) { throw new IllegalArgumentException("fileName can not be blank."); }
public FileRender(String fileName, String downloadFileName) { this(fileName);
if (StrKit.isBlank(downloadFileName)) { throw new IllegalArgumentException("downloadFileName can not be blank."); } this.downloadFileName = downloadFileName; init(); }
log4j.com.jfinal.render.FileRender = OFF
不太记得配置细节了,上面的配置可能是错误的,如果不对,再试试下面这个:
log4j.org.apache.catalina.connector.ClientAbortException = OFF
还有一个更好的办法就是通过继承 RenderFactory 并覆盖掉 getFileRender() 方法,接管这个以后用自己的 MyFileRender extends FileRender 来代替原来的实现
在 MyFileRender 中的大致代码如下:
try {
super.render();
} catch(Exception e) {
if (e.getMessage().contains("ClientAbortException") ) {
// 忽略;
} else {
throw new RuntimeException(e);
}
}