Netty received message printing problems

Demand: Netty server after receiving the message, you need to display the complete original data packets received, for example, the client sends a 0x31, that server is also displayed 0x31, rather than the converted data format.

Start with a routine method:


System.out.println("服务器收到数据2:"+in.toString(CharsetUtil.UTF_8));

Which, in the data is received on the server, the format is bytebuf.

In this manner, the client sends 0x31, shown as server 1, i.e. the corresponding character 0x31. This is not the functional requirements;

Later changed to:

String str= ByteBufUtil.hexDump(in).toUpperCase();
System.out.println("服务器收到数据1:"+str);

It can be.

Published 125 original articles · won praise 9 · views 30000 +

Guess you like

Origin blog.csdn.net/jiezhang656/article/details/104752377