From 049c514ea4fd378e2587245a9e113398c6da173c Mon Sep 17 00:00:00 2001 From: landy Date: Sun, 16 Jun 2019 10:40:20 +0800 Subject: [PATCH] Fixed a bug for IOException since the FileBaseDirectory not exists --- .../fortune/doc/server/support/DocServerHandler.java | 10 ++++++++++ .../src/main/resources/config/doc-server.yml | 2 +- .../src/main/webapp/META-INF/MANIFEST.MF | 3 +++ commons-doc-server-netty/src/main/webapp/index.jsp | 12 ++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 commons-doc-server-netty/src/main/webapp/META-INF/MANIFEST.MF create mode 100644 commons-doc-server-netty/src/main/webapp/index.jsp diff --git a/commons-doc-server-netty/src/main/java/org/fortune/doc/server/support/DocServerHandler.java b/commons-doc-server-netty/src/main/java/org/fortune/doc/server/support/DocServerHandler.java index 99caaff..e60f4b6 100644 --- a/commons-doc-server-netty/src/main/java/org/fortune/doc/server/support/DocServerHandler.java +++ b/commons-doc-server-netty/src/main/java/org/fortune/doc/server/support/DocServerHandler.java @@ -17,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.net.URI; /** @@ -283,6 +284,7 @@ private void writeMenu(MessageEvent e) { } static { + createFileBaseDirectoryIfNotExist(); org.jboss.netty.handler.codec.http.multipart.DiskFileUpload.deleteOnExitTemporaryFile = false; org.jboss.netty.handler.codec.http.multipart.DiskFileUpload.baseDirectory = DocServerContainer .getInstance().getFileBaseDirectory(); @@ -291,4 +293,12 @@ private void writeMenu(MessageEvent e) { .getInstance().getFileBaseDirectory(); } + //2019.06.16 修复【系统找不到指定路径】的异常问题 + private static void createFileBaseDirectoryIfNotExist() { + String fileDir = DocServerContainer.getInstance().getFileBaseDirectory(); + File dirFolder = new File(fileDir); + + if (!dirFolder.exists()) + dirFolder.mkdirs(); + } } diff --git a/commons-doc-server-netty/src/main/resources/config/doc-server.yml b/commons-doc-server-netty/src/main/resources/config/doc-server.yml index 7958270..be5ae4f 100644 --- a/commons-doc-server-netty/src/main/resources/config/doc-server.yml +++ b/commons-doc-server-netty/src/main/resources/config/doc-server.yml @@ -14,4 +14,4 @@ accounts: thumbHeight: 100 thumbWidth: 100 port: 9999 #端口号 -fileBaseDirectory: C:\06_temp\upload\tmp #临时文件的目录 \ No newline at end of file +fileBaseDirectory: C:\06_temp\up\tmp #临时文件的目录 \ No newline at end of file diff --git a/commons-doc-server-netty/src/main/webapp/META-INF/MANIFEST.MF b/commons-doc-server-netty/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/commons-doc-server-netty/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/commons-doc-server-netty/src/main/webapp/index.jsp b/commons-doc-server-netty/src/main/webapp/index.jsp new file mode 100644 index 0000000..e24eb9b --- /dev/null +++ b/commons-doc-server-netty/src/main/webapp/index.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Commons-Doc-Server + + +静态资源服务器部署成功 + + \ No newline at end of file