Scalatra不会安装新服务

时间:2015-10-10 18:21:36

标签: scala scalatra

我正在尝试将服务挂载到scalatra但是在编译并启动应用程序GET /logging后scalatra无法识别

ScalatraBootstrap.scala

import org.scalatra._
import javax.servlet.ServletContext


class ScalatraBootstrap extends LifeCycle {
  override  def init(context: ServletContext): Unit = {
    context mount(new LoggingService, "/logging/*")
  }
}

LoggingService.scala

import org.scalatra._

class LoggingService extends ScalatraServlet {
  get("/*") {
    "hello"
  }
}

我得到了

Requesting "GET /logging/" on servlet "" but only have:
GET /

提前致谢

1 个答案:

答案 0 :(得分:1)

也许这会解决它。

get("/") {
   "hello"
}
context mount(new LoggingService, "/logging/*")

“/ logging / *”表示它将使用prefix / logging /

添加所有内容

实施例

get("/") {
    "hello"
}

get("/1") {
    "hello1"
}

get("/2") {
    "hello2"
}

使用“/ logging”,“/ logging / 1”或“/ logging / 2”