~~~ package org.jeecg.config; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.http.HttpRequest; import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.stereotype.Component; import reactor.netty.ConnectionObserver; import reactor.netty.NettyPipeline; import java.io.UnsupportedEncodingException; @Component public class MyNettyWebServerCustomizer implements WebServerFactoryCustomizer<NettyReactiveWebServerFactory> { @Override public void customize(NettyReactiveWebServerFactory factory) { factory.addServerCustomizers(httpServer -> httpServer.observe((conn, state) -> { if (state == ConnectionObserver.State.CONNECTED) { conn.channel().pipeline().addAfter(NettyPipeline.HttpCodec, "", new QueryHandler()); } }) ); } static final class QueryHandler extends ChannelInboundHandlerAdapter { static final QueryHandler INSTANCE = new QueryHandler(); @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws UnsupportedEncodingException { if (msg instanceof HttpRequest) { HttpRequest request = (HttpRequest) msg; String url = request.uri(); //TODO 替换特殊字符 request.setUri(url); } ctx.fireChannelRead(msg); } @Override public boolean isSharable() { return true; } } } ~~~