Http服务器-Netty实现 代码实现 server实现 Handler实现 测试 Get请求 POST请求 解析请求中的参数 GET请求 POST请求 附- 类继承图 Request Response 代码实现 server实现 public class HttpServer2 { private int port; public HttpServer2(int port) { this.port = port; } public void start(){ EventLoopGroup boss = new NioEventLoopGroup(); EventLoopGroup worker = new NioEventLoopGroup(); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(boss, worker).channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); // 编解码 pipeline.addLast(new HttpServerCodec()); // 自定义处理器 pipeline.addLast(new HttpHandler2()); } }