在jetty 8中配置Web应用程序外部的静态资源文件夹

时间:2014-04-02 08:18:57

标签: java jetty xml-configuration

我在Web应用程序外部有一个静态资源文件夹,我正在尝试在Jetty 8中配置它。到目前为止,我已经尝试了以下内容。

1)我在jetty xml中添加了一个上下文处理程序,如下所示:

    <Set name="handler">
  <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
    <Set name="handlers">
     <Array type="org.eclipse.jetty.server.Handler">
      <Item>
        <New id="context" class="org.eclipse.jetty.server.handler.ContextHandler">
         <Set name="resourceBase"><SystemProperty name="JETTY_HOME" default="."/>/static/</Set>
        </New>
      </Item>
       <Item>
         <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
       </Item>
       <Item>
         <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
       </Item>
     </Array>
    </Set>
  </New>
</Set>

我已将静态文件夹放在jetty-distribution文件夹中。

我还尝试将静态文件夹作为static.war放在webapps文件夹中,并且无法使用/ static访问它。

2)我尝试在jetty发行版的/ contexts文件夹中添加/更改xml。即使这样也行不通。

另外,在我的jetty-web.xml中,我有一个webappcontext注册如下:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
 <Call class="org.eclipse.jetty.util.log.Log" name="debug">
    <Arg>executing jetty-web.xml</Arg>
 </Call>
 <Set name="contextPath">/security</Set>
 </Configure>

我的静态资源结构如下。

   static
     -css
       - <all css files>
     -images
       - <further folders and images>
     -js
       - <all js files>

我是码头新手,过去几天开始从事这项工作。任何帮助都非常感谢。

由于

0 个答案:

没有答案
相关问题