java 请解释 RestTemplate
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4721279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Please explain RestTemplate
提问by Some Java Guy
I have a class
我有一堂课
public class Client extends RestTemplate
// org.springframework.web.client.RestTemplate
What is RestTemplate used for?
RestTemplate 有什么用?
回答by uncaught_exceptions
I assume you understand the concept of templating in spring. (its based on a design patten with the same name). RestTemplate is a template used to make HTTP Rest Calls (REST Client).
我假设您了解春季模板的概念。(它基于同名的设计模式)。RestTemplate 是用于进行 HTTP Rest 调用(REST 客户端)的模板。
If you want to make a HTTP Call, you need to create a HttpClient, pass request and (or) form parameters, setup accept headers and perform unmarshalling of response, all by yourself, Spring Rest Templates, tries to take the pain away by abstracting all these details from you.
如果你想进行 HTTP 调用,你需要创建一个 HttpClient,传递请求和(或)表单参数,设置接受头并执行响应的解组,全部由你自己,Spring Rest Templates,试图通过抽象来消除痛苦所有这些细节都来自你。
http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/
http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/