我有如下层次结构
--> 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 目录中的任何文件?
最佳答案
听起来您只是缺少导入语句。可能是这个:
import spray.httpx.marshalling.Marshaller
编辑
没关系。 getFromResourceDirectory 不需要是完整的:
val webRoute = path("web") {
get {
entity(as[String]) {
thePath =>
getFromResourceDirectory(thePath)
}
}
}
关于java - 使用 spray 服务分层静态内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23931862/