如何使用Java在高服务器Http Akka中加载两级路由?

如何使用Java在高服务器Http Akka中加载两级路由?,java,akka,akka-http,Java,Akka,Akka Http,我正在尝试使用akka Http和Java一起工作 我想加载一条如下所示的路线: hello/world 在我的HttpApp上,我尝试了: return route( path("hello/world", () -> get(() -> complete("<h1>Say hello to akka-http</h1&g

我正在尝试使用
akka Http
Java
一起工作

我想加载一条如下所示的路线:
hello/world

在我的
HttpApp
上,我尝试了:

return route(
                path("hello/world", () ->
                        get(() ->
                                complete("<h1>Say hello to akka-http</h1>")
                        )
                );
返回路线(
路径(“你好/世界”,()->
得到(()->
完成(“向akka http问好”)
)
);

请按照以下步骤进行尝试

导入静态akka.http.javadsl.server.PathMatchers.*;
回程(
路径(段(“你好”)。斜线(段(“世界”),()->
得到(()->
完成(“向akka http问好”)
)
);

我尝试过,但不起作用。我遇到以下错误:-无法解析方法段(java.lang.String)-无法解析方法斜杠(java.lang.String)。在事实中,Intellij IDEA autocomplete不适用于段或斜杠函数。您可能缺少导入。我已将其添加到答案中。
import static akka.http.javadsl.server.PathMatchers.*;

return route(
  path(segment("hello").slash(segment("world")), () ->
    get(() ->
     complete("<h1>Say hello to akka-http</h1>")
    )
);