4

私はscalatra-sbt.g8に基づいて次のことを試みています:

class FooWeb extends ScalatraServlet with ScalateSupport {
  beforeAll { contentType = "text/html" }
  get("/") {
    templateEngine.layout("/WEB-INF/scalate/templates/hello-scalate.jade")
  }
}

しかし、次の例外が発生します(ファイルが存在していても)-手がかりはありますか?

Could not load resource: [/WEB-INF/scalate/templates/hello-scalate.jade]; are you sure it's within [null]?

org.fusesource.scalate.util.ResourceNotFoundException: Could not load resource: [/WEB-INF/scalate/templates/hello-scalate.jade]; are you sure it's within [null]?

org.mortbay.jetty.handler.ContextHandler.getResourceFWIW、最も内側の例外は行1142から来ています: _baseResource==null

4

1 に答える 1

5

scalatraメーリングリストから回答を得ました。問題は、次のように Jetty サーバーを起動していたことです。

import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.{Context,ServletHolder}
val server = new Server(8080)
val root = new Context(server, "/", Context.SESSIONS)
root.addServlet(new ServletHolder(new FooWeb()), "/*")
server.start()

前にこれを挿入する必要がありましたstart()

root.setResourceBase("src/main/webapp")
于 2011-07-20T04:18:06.850 に答える