Browse Source

jfinal 1.9 release ^_^

James 11 years ago
parent
commit
af6469eb6f
1 changed files with 2 additions and 8 deletions
  1. 2 8
      src/com/jfinal/render/FileRender.java

+ 2 - 8
src/com/jfinal/render/FileRender.java

@@ -36,7 +36,6 @@ public class FileRender extends Render {
 	private static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
 	
 	private File file;
-	private String fileName;
 	private static String fileDownloadPath;
 	private static ServletContext servletContext;
 	private static String webRootPath;
@@ -46,7 +45,8 @@ public class FileRender extends Render {
 	}
 	
 	public FileRender(String fileName) {
-		this.fileName = fileName;
+		fileName = fileName.startsWith("/") ? webRootPath + fileName : fileDownloadPath + fileName;
+		this.file = new File(fileName);
 	}
 	
 	static void init(String fileDownloadPath, ServletContext servletContext) {
@@ -56,12 +56,6 @@ public class FileRender extends Render {
 	}
 	
 	public void render() {
-		if (fileName != null) {
-			if (fileName.startsWith("/"))
-				file = new File(webRootPath + fileName);
-			else
-				file = new File(fileDownloadPath + fileName);
-		}
 		if (file == null || !file.isFile()) {
 			RenderFactory.me().getErrorRender(404).setContext(request, response).render();
 			return ;