我正在尝试将服务挂载到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 /
提前致谢
答案 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”