diff --git a/jcommon/docean/pom.xml b/jcommon/docean/pom.xml
index 5e4621c9e..af119859a 100644
--- a/jcommon/docean/pom.xml
+++ b/jcommon/docean/pom.xml
@@ -16,8 +16,8 @@
run.mone
easy
-
- 1.5.0-jdk21
+ 1.4-jdk21-SNAPSHOT
+
cglib
diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java
index d6cd74510..df8f4804f 100644
--- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java
+++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java
@@ -78,6 +78,10 @@ private void setConfig(Ioc ioc) {
this.mvcConfig.setAllowCross(Boolean.valueOf(ioc.getBean(MvcConst.ALLOW_CROSS_DOMAIN, MvcConst.FALSE)));
this.mvcConfig.setDownload(Boolean.valueOf(ioc.getBean(MvcConst.MVC_DOWNLOAD, MvcConst.FALSE)));
this.mvcConfig.setUseCglib(Boolean.valueOf(ioc.getBean(MvcConst.CGLIB, MvcConst.TRUE)));
+
+ this.mvcConfig.setOpenStaticFile(Boolean.valueOf(ioc.getBean(MvcConst.OPEN_STATIC_FILE, MvcConst.FALSE)));
+ this.mvcConfig.setStaticFilePath(ioc.getBean(MvcConst.STATIC_FILE_PATH, MvcConst.EMPTY));
+
this.mvcConfig.setResponseOriginalValue(Boolean.valueOf(ioc.getBean(MvcConst.RESPONSE_ORIGINAL_VALUE, MvcConst.FALSE)));
this.mvcConfig.setPoolSize(Integer.valueOf(ioc.getBean(MvcConst.MVC_POOL_SIZE, String.valueOf(MvcConst.DEFAULT_MVC_POOL_SIZE))));
this.mvcConfig.setVirtualThread(Boolean.valueOf(ioc.getBean(MvcConst.VIRTUAL_THREAD, MvcConst.TRUE)));
diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/bo/MvcConfig.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/bo/MvcConfig.java
index 6159d4b91..f93e818ca 100644
--- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/bo/MvcConfig.java
+++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/bo/MvcConfig.java
@@ -38,4 +38,8 @@ public class MvcConfig implements Serializable {
*/
private boolean virtualThread;
+ private String staticFilePath;
+
+ private boolean openStaticFile;
+
}
diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/config/HttpServerConfig.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/config/HttpServerConfig.java
index 904a0ee18..2b8780eb5 100644
--- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/config/HttpServerConfig.java
+++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/config/HttpServerConfig.java
@@ -52,10 +52,9 @@ public class HttpServerConfig {
private boolean userWs;
-
public static int HTTP_POOL_SIZE = 500;
- public static int HTTP_POOL_QUEUE_SIZE = 1000;
+ public static int HTTP_POOL_QUEUE_SIZE = 1000;
public enum HttpVersion {
http1, http2
diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/mvc/MvcRunnable.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/mvc/MvcRunnable.java
index 20a94e674..ea1ebdd13 100644
--- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/mvc/MvcRunnable.java
+++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/mvc/MvcRunnable.java
@@ -2,11 +2,14 @@
import com.google.gson.Gson;
import com.xiaomi.youpin.docean.Mvc;
+import com.xiaomi.youpin.docean.bo.MvcConfig;
import com.xiaomi.youpin.docean.common.Cons;
import com.xiaomi.youpin.docean.common.Safe;
+import com.xiaomi.youpin.docean.common.StringUtils;
import com.xiaomi.youpin.docean.config.HttpServerConfig;
import com.xiaomi.youpin.docean.mvc.common.MvcConst;
import com.xiaomi.youpin.docean.mvc.download.Download;
+import com.xiaomi.youpin.docean.mvc.html.Html;
import com.xiaomi.youpin.docean.mvc.upload.MvcUpload;
import com.xiaomi.youpin.docean.mvc.util.ExceptionUtil;
import com.xiaomi.youpin.docean.mvc.util.MethodFinder;
@@ -31,6 +34,8 @@ public class MvcRunnable implements Runnable {
private MvcResponse response;
+ private MvcConfig config;
+
private ConcurrentHashMap requestMethodMap;
private Mvc mvc;
@@ -43,6 +48,7 @@ public MvcRunnable(Mvc mvc, MvcContext context, MvcRequest request, MvcResponse
this.response = response;
this.requestMethodMap = requestMethodMap;
this.mvc = mvc;
+ this.config = this.mvc.getMvcConfig();
}
@@ -65,6 +71,7 @@ public MvcRunnable(Mvc mvc, HttpServerConfig config, ChannelHandlerContext ctx,
this.request.setBody(body);
this.response.setCtx(ctx);
this.mvc = mvc;
+ this.config = this.mvc.getMvcConfig();
this.requestMethodMap = requestMethodMap;
}
@@ -107,6 +114,17 @@ private void call() {
}
String path = request.getPath();
+
+ if (config.isOpenStaticFile() && Html.isHtmlFile(path)) {
+ String content = Html.view(config.getStaticFilePath() + path);
+ if (StringUtils.isEmpty(content)) {
+ sendNotFoundResponse();
+ return;
+ }
+ response.writeAndFlush(context, content);
+ return;
+ }
+
//Support file download (/download) and must enable downloads.
if (isDownload(path) && mvc.getMvcConfig().isDownload()) {
Download.download(context, request, response);
@@ -127,16 +145,20 @@ private void call() {
}
if (!path.equals(Cons.Service)) {
- MvcResult