Browse Source

Merge pull request #1403 in DESIGN/design from ~RINOUX/design:release/10.0 to release/10.0

* commit '293d1e96755afcd5066acc63ba852dda1cad442e':
  REPORT-25986 设置一下资源根目录,否则无法通过ServletContext.getResource读到工程文件
feature/big-screen
rinoux 5 years ago
parent
commit
93177f5ed7
  1. 11
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

11
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -1,6 +1,5 @@
package com.fr.start.server;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.log.FineLoggerFactory;
import com.fr.module.Activator;
@ -15,6 +14,7 @@ import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.StandardRoot;
import java.io.File;
import java.util.HashSet;
@ -63,10 +63,11 @@ public class FineEmbedServerActivator extends Activator {
// 设置解码uri使用的字符编码
tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8);
String docBase = new File(WorkContext.getCurrent().getPath()).getParent();
//内置的上下文是自己定的,这里把WEB_APP_NAME一并设置了,否则下面appName是/null
ProductConstants.setWebAppName(ProductConstants.getAppFolderName());
String appName = "/" + FRContext.getCommonOperator().getAppName();
Context context = tomcat.addContext(appName, docBase);
//内置的上下文使用工程目录比如webroot
String contextPath = "/" + ProductConstants.getAppFolderName();
final Context context = tomcat.addContext(contextPath, docBase);
context.setResources(new StandardRoot(context));
Tomcat.initWebappDefaults(context);
//覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader());

Loading…
Cancel
Save