用喷雾服务分层静态内容

时间:2014-05-29 11:05:16

标签: java javascript scala tomcat spray

我的层次结构如下

--> myexample.war
  --> WEB-INF
  --> web
    --> admin
      --> index.html
      --> js
        --> somejs.js

我的喷雾路线应该是什么? (需要使用喷雾)。

我试过

  val webRoute = path("web") {
    get {
      entity(as[String]) {
        thePath =>
          complete(getFromResourceDirectory(thePath))
      }
    }
  }

获得:

> error: could not find implicit value for parameter marshaller:
> spray.httpx.marshalling.ToResponseMarshaller[spray.routing.RequestContext
> => Unit]

但它似乎不正确,我该如何使用它来提供 web 目录中的任何文件?

1 个答案:

答案 0 :(得分:3)

听起来你只是缺少一个import语句。可能就是这个:

import spray.httpx.marshalling.Marshaller

修改

没关系。 getFromResourceDirectory不需要完整:

  val webRoute = path("web") {
    get {
      entity(as[String]) {
        thePath =>
          getFromResourceDirectory(thePath)
      }
    }
  }