在码头部署静态内容

我正在尝试在码头中部署静态应用程序,但使用 xml 配置文件,因为我使用的是虚拟主机。


我为部署创建了这个文件 xml:


<?xml version="1.0"  encoding="ISO-8859-1"?>

<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 

  "http://www.eclipse.org/jetty/configure.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

    <Set name="contextPath">/mail</Set>

    <!--<Call name="setInitParameter">

        <Arg>org.eclipse.jetty.servlet.Default.useFileMappedBuffer</Arg>

        <Arg>false</Arg>

    </Call> -->

    <Set name="handler">

    <New class="org.eclipse.jetty.server.handler.ResourceHandler">

      <Set name="resourceBase">/ccmail</Set>

      <Set name="directoriesListed">true</Set>

    </New>

  </Set>


    <Set name="virtualHosts">

    <Array type="java.lang.String">

      <Item>apps.cairunet.ad.br</Item>     

    </Array>

  </Set> 


</Configure>

我的文件夹应用程序的名称是ccmail. 位于webapps/ccmail 我已经尝试传递到路径:


<Set name="resourceBase">/ccmail</Set>


<Set name="resourceBase">ccmail</Set>


<Set name="resourceBase">./ccmail</Set>


<Set name="resourceBase">webapps/ccmail</Set>


<Set name="resourceBase">/webapps/ccmail</Set>


任何这条路径都不适合我的人。


码头启动此错误:


2019-02-25 09:36:46.422:WARN:oejs.ServletContextHandler:main: 不应直接调用 ServletContextHandler.setHandler。使用 insertHandler 或 setSessionHandler 等 2019-02-25 09:36:46.484:WARN:oejw.WebInfConfiguration:main: Can't generate resourceBase 作为 webapp tmp dir name: java.lang.IllegalStateException: No resourceBase or war set for上下文 2019-02-25 09:36:46.500:WARN:oejw.WebAppContext:main: 上下文 oejwWebAppContext@7d0587f1{/mail,nul 启动失败

手掌心
浏览 132回答 1
1回答

慕村225694

注意:请注意您的 DOCTYPE,您声明的内容来自 Jetty 7.x 到 Jetty 8.x,不适用于 Jetty 9.x不要混用 ResourceHandler 和 WebAppContext / ServletContextHandler。<?xml version="1.0"&nbsp; encoding="ISO-8859-1"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"&nbsp; &nbsp;"http://www.eclipse.org/jetty/configure_9_3.dtd"><Configure class="org.eclipse.jetty.webapp.WebAppContext">&nbsp; <Set name="contextPath">/mail</Set>&nbsp; <Set name="virtualHosts">&nbsp; &nbsp; <Array type="java.lang.String">&nbsp; &nbsp; &nbsp; <Item>apps.cairunet.ad.br</Item>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </Array>&nbsp; </Set>&nbsp;</Configure>最基本的支持是不要/ccmail在你的<Configure>.它存在的事实${jetty.base}/webapps/ccmail/就足够了,它将/ccmail为您部署为静态资源库。但是,如果您想将静态资源与虚拟主机结合起来,那么您可以使用带有备用基础的 WebAppContext 或新的 ResourceHandler。ResourceHandler 使用示例: https ://www.eclipse.org/jetty/documentation/current/static-content-deployment.html<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"&nbsp; &nbsp;"http://www.eclipse.org/jetty/configure_9_3.dtd"><Configure class="org.eclipse.jetty.server.handler.ContextHandler">&nbsp; <Set name="contextPath">/ccmail</Set>&nbsp; <Set name="handler">&nbsp; &nbsp; <New class="org.eclipse.jetty.server.handler.ResourceHandler">&nbsp; &nbsp; &nbsp; <Set name="resourceBase">/fully/qualified/path/to/my/jetty.base/webapps/ccmail</Set>&nbsp; &nbsp; &nbsp; <Set name="directoriesListed">true</Set>&nbsp; &nbsp; </New>&nbsp; </Set>&nbsp; <Set name="virtualHosts">&nbsp; &nbsp; <Array type="java.lang.String">&nbsp; &nbsp; &nbsp; <Item>apps.cairunet.ad.br</Item>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </Array>&nbsp; </Set>&nbsp;</Configure>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java