Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HttpExchange到达时为空_Java_Inputstream_Handle_Httpserver - Fatal编程技术网

Java HttpExchange到达时为空

Java HttpExchange到达时为空,java,inputstream,handle,httpserver,Java,Inputstream,Handle,Httpserver,我已经基于com.sun.net.HttpServer.HttpExchange创建了一个HttpServer。 在我的处理程序com.sun.net.httpserver.HttpHandler的实现中,方法public void handle(HttpExchange exchange)获取一个请求体为空的交换。 在服务器端,我正在使用: server.createContext("/", new BbHandler()); String url = "http://localhost:2

我已经基于com.sun.net.HttpServer.HttpExchange创建了一个HttpServer。 在我的处理程序com.sun.net.httpserver.HttpHandler的实现中,方法public void handle(HttpExchange exchange)获取一个请求体为空的交换。 在服务器端,我正在使用:

server.createContext("/", new BbHandler());
String url = "http://localhost:22334/name=john";
在我的Midlet客户端上,我正在使用:

server.createContext("/", new BbHandler());
String url = "http://localhost:22334/name=john";
为什么exchange的requestBody没有数据可读取? 谢谢
Eyal.

最可能的原因是没有可阅读的正文。您提供的字段位于URL中,可以在exchange对象的getRequestURI()调用中使用(尽管它可能不在URI对象的getQuery()部分,因为它缺少URI期望用于查询参数的分隔符),但正文中没有任何内容。大多数情况下,GET请求没有正文内容,而PUTPOST请求则没有正文内容