本文介绍了为什么我得到“找不到请求的资源."什么时候进入简单的喷雾路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了一个简单的喷雾示例应用程序,但无法访问路由,我上传了不起作用的示例源代码到 github:spray-tomcat-example:

I tried a simple spray example app and i cannot access the route, I uploaded the example source code which does not work to github: spray-tomcat-example:

 git clone https://github.com/avidanyum/spray-tomcat-example
 mvn package
 cp cp target/spray-tomcat-example-0.1-SNAPSHOT.war ~/tmp/tomcat/apache-tomcat-7.0.61/webapps/spraytomcat.war
 cd ~/tmp/tomcat/apache-tomcat-7.0.61/bin
 ./catalina.sh jpda run
 http://localhost:8080/spraytomcat/

我明白

"The requested resource could not be found."

我定义的路线如下:

class ServiceActor extends Actor with Service {

  def actorRefFactory = context
  def receive = runRoute(myRoute)
}

trait Service extends HttpService {
  import com.example.domain.Person

  val myRoute =
    path("") {
      get {
        respondWithMediaType(`text/html`) {
          complete {
            <html>
              <body>
                <h1>Say hello to <i>spray-routing</i> on <i>tomcat</i>!</h1>
              </body>
            </html>
          }
        }
      }
    }


}

当然我有 boot

application.conf

spray.servlet {
  boot-class = "com.example.SprayBoot"
  request-timeout = 10s
}

SprayBoot 本身:

class SprayBoot extends WebBoot {

  val system = ActorSystem("actorsystem")
  val serviceActor = system.actorOf(Props[ServiceActor])

}

我很确定我遵循了所有要求,我是否遗漏了什么?如何更新它以实际提供内容而不是找不到请求的资源."

I'm pretty sure I followed all requirements am i missing something? how can I update it to actually serve the content instead of "The requested resource could not be found."

推荐答案

如@jrudolph 所说

as @jrudolph said

问题似乎是喷雾没有剥离上下文小路.所以,你需要设置spray.servlet.root-path = "/spraytomcat"设置使其工作.请参阅此处

这篇关于为什么我得到“找不到请求的资源."什么时候进入简单的喷雾路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 20:01