Browse Source

无JIRA任务 静态资源servlet添加的方式不对,修改下

master
ju 7 years ago
parent
commit
7f1226324f
  1. 16
      designer-base/src/com/fr/start/server/FineEmbedServerActivator.java

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

@ -11,6 +11,7 @@ import com.fr.third.springframework.web.SpringServletContainerInitializer;
import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.loader.VirtualWebappLoader; import org.apache.catalina.loader.VirtualWebappLoader;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
@ -57,7 +58,7 @@ public class FineEmbedServerActivator extends Activator {
String docBase = new File(FRContext.getCurrentEnv().getPath()).getParent(); String docBase = new File(FRContext.getCurrentEnv().getPath()).getParent();
String appName = "/" + FRContext.getCurrentEnv().getAppName(); String appName = "/" + FRContext.getCurrentEnv().getAppName();
Context context = tomcat.addContext(appName, docBase); Context context = tomcat.addContext(appName, docBase);
tomcat.addServlet(appName, "default", "org.apache.catalina.servlets.DefaultServlet"); addDefaultServlet(context);
//覆盖tomcat的WebAppClassLoader //覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader()); context.setLoader(new FRTomcatLoader());
@ -68,6 +69,19 @@ public class FineEmbedServerActivator extends Activator {
context.addServletContainerInitializer(initializer, classes); context.addServletContainerInitializer(initializer, classes);
} }
private void addDefaultServlet(Context context) {
Wrapper defaultServlet = context.createWrapper();
defaultServlet.setName("default");
defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
defaultServlet.addInitParameter("debug", "0");
defaultServlet.addInitParameter("listings", "false");
defaultServlet.setLoadOnStartup(1);
defaultServlet.setOverridable(true);
context.addChild(defaultServlet);
context.addServletMapping("/","default");
}
private void stopServerActivator() { private void stopServerActivator() {

Loading…
Cancel
Save