簡體   English   中英

這種調用http請求get的語法有什么問題

[英]where is the wrong in this syntax of calling http request get

我有這個電話(來自瀏覽器)

http://serverName:8081/cmp-mg-?sub_x?=7

它返回 200 響應

我想從我的網絡服務調用執行該請求:

這是我的網絡服務:

public Response sendMT2(@BeanParam MT mt) throws IOException {
        try {
            HttpHost host = new HttpHost("serverName", 8081);
            HttpClient client = HttpClientBuilder.create().build();
            HttpRequest request = new BasicHttpRequest("GET",
                    "/serverp/sam?" + mt.getURLParameter());
            System.out.println("/cmp-mg-xconn-http-webapp/sam?"
                    + mt.getURLParameter());
            HttpResponse response = client.execute(host, request);
            String responseString = new BasicResponseHandler()
                    .handleResponse(response);
            return Response.ok(responseString).build();
        } catch (ClientProtocolException e) {
            throw e;
            // return Response.status(500).build();
        } catch (IOException e) {
            throw e;
            // return Response.status(500).build();
        }
    }

但我收到錯誤

org.apache.http.client.HttpResponseException: Not Found

怎么了?

我自己發現了錯誤。

在 sub-r_mob 之前 .. 我有? 而不是&

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM