Jetty的外部静态资源

时间:2013-03-29 01:06:58

标签: jetty embedded-jetty maven-jetty-plugin

我有以下Jetty配置:

<webAppConfig>
   <defaultsDescriptor>${project.basedir}/configuration/webdefaults.xml</defaultsDescriptor>
   <contextPath>/app</contextPath>
   <baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
      <resourcesAsCSV>${project.basedir}/src/main/webapp,/external/dir,/another/dir</resourcesAsCSV>
   </baseResource>
</webAppConfig>

现在,在我的src / main / webapp和/ external / dir中,我有一个名为static的目录,两者的资源都可以通过URL / app / static访问。然而,在/ another / dir中,我有一个名为special-static的目录,由于某种原因,其中的资源无法访问(或者至少不使用URL / app / special-static)。

知道我可能做错了吗?

2 个答案:

答案 0 :(得分:0)

xml条目......

<resourcesAsCSV>dir1,dir2,dir3</resourcesAsCSV>

采用[C] omma [S] eparated [V],在配置中使用","而不是";"

答案 1 :(得分:0)

您使用的是哪个版本?

对于版本8或9,我会做类似的事情:

 <webAppConfig>
  ...
  <resourceBases>
   <resourceBase>${project.basedir}/src/main/webapp</resourceBase>
   <resourceBase>/external/dir</resourceBase>
   <resourceBase>/another/dir</resourceBase>
  </resourceBases>
 </webAppConfig>

如果您使用的是过期版本(6或7),我建议您升级到最新版本8.