Jetty错误:此URL不支持HTTP方法GET

问题描述 投票:0回答:1

我正在使用HTTP4S,并且webapp正在码头运行。 Web应用程序文件配置为:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">


   <servlet>
      <servlet-name>user-svc</servlet-name>
      <servlet-class>io.databaker.UserSvcServlet</servlet-class>
      <async-supported>true</async-supported>
   </servlet>

   <servlet-mapping>
      <servlet-name>user-svc</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>

</web-app>

可用的URI是:

object UserSvcRoutes {

  def helloWorldRoutes[F[_]: Sync](H: HelloWorld[F]): HttpRoutes[F] = {
    val dsl = new Http4sDsl[F]{}
    import dsl._
    HttpRoutes.of[F] {
      case GET -> Root =>
        Ok("Example")
      case GET -> Root / "hello" / name =>
        for {
          greeting <- H.hello(HelloWorld.Name(name))
          resp <- Ok(greeting)
        } yield resp
    }
  }

}

当我打电话给http://localhost:8080/时,我得到了:

enter image description here我做错了什么?

scala servlets http4s xsbt-web-plugin
1个回答
0
投票

[Http4sServlet最近被抽象化,Http4sServletBlockingHttp4sServlet提供了两个具体的实现。

您可以通过更改BlockingHttp4sServlet来扩展其中任何一个来使示例工作:

AsyncHttp4sServlet
© www.soinside.com 2019 - 2024. All rights reserved.