0

我正在尝试为 Http 设置 Netty Server 4.15。我已经设置了我的 Html 编码器/解码器,以及请求处理程序。我这样声明:

  public void run() throws Exception {
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup(1);
    try {
      ServerBootstrap b = new ServerBootstrap();
      b.group(bossGroup, workerGroup)
          .channel(NioServerSocketChannel.class)
          .handler(new LoggingHandler(LogLevel.INFO))
          .childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel ch) throws Exception {
              ChannelPipeline p = ch.pipeline();
              p.addLast(new HttpRequestDecoder());
              p.addLast(new HttpResponseEncoder());
              p.addLast(new NettyHttpHandler());
            }
          });

      ChannelFuture f = b.bind(port)
          .sync();
      f.channel()
          .closeFuture()
          .sync();

    } finally {
      bossGroup.shutdownGracefully();
      workerGroup.shutdownGracefully();
    }
  }

当我去的时候这很好用

localhost:8080?param=param1&param2=param2

如何配置它以使其仅适用于某个 URL?喜欢

localhost:8080/myendpoint?param=param1&param2=param2
4

0 回答 0