调用http请求get的语法中哪里出错了

时间:2015-10-19 11:12:54

标签: java http get httprequest

我有这个电话(来自浏览器)

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

有什么不对?

1 个答案:

答案 0 :(得分:0)

我自己发现了错误。

在sub-r_mob之前

我有?而不是&