Nar*_*yan 6 java spring-mvc dropwizard
我找了类似的问题,却找不到任何问题.我有一个使用drop-wizard创建的微服务,该服务在localhost:9000中运行.
我在另一个项目(与Spring MVC的)工作在8080上运行我婉调用上述服务,这给了我的字符串返回从任我在主体工程.lets控制器的说的路径是"本地主机:9000/giveMeString".
您可以使用Apache的HTTP客户端。请参阅从其文档中借用的以下示例:
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
GetMethod method = new GetMethod("http://localhost:9000/giveMeString");
// Execute the method.
int statusCode = client.executeMethod(method);
// Read the response body.
byte[] responseBody = method.getResponseBody();
//Print the response
System.out.println(new String(responseBody));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5868 次 |
| 最近记录: |