我已经实现了 com.sun.net.httpserver.HttpServer:
HttpServer server = HttpServer.create(new InetSocketAddress(8001), 0);
server.createContext("/myserver", new myHttpHandler());
server.createContext("/myserver/get", new GetHttpHandler());
我想使用以下 url 将参数传递给 /myserver/get:
http://localhost:8000/myserver/get?deviceid=ABB00122
static class GetHttpHandler implements HttpHandler {
public void handle(HttpExchange exchange) throws IOException {
// how do I now access the deviceid?
}
}
如何访问我在句柄方法中使用我的 url 发送的参数 deviceid?