Android Annotation 3.1如何在resttemplate中注入requestfactory
如何将其注入RestTemplate android注释Android Annotation 3.1如何在resttemplate中注入requestfactory,android,spring,android-annotations,Android,Spring,Android Annotations,如何将其注入RestTemplate android注释 String url = "site"; HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); connection.setDefaultUseCaches(true); connection.setUseCaches(true); connection.addRequestProperty("Cache-Co
String url = "site";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setDefaultUseCaches(true);
connection.setUseCaches(true);
connection.addRequestProperty("Cache-Control", "max-stale=" + 10);
您可以在restemplate
中查看并获得如何使用AndroidAnnotations注入请求工厂的示例。
主要步骤是:
- 创建一个实现
或扩展clienthtprequestfactory
的类。这个类可以用SimpleClientHttpRequestFactory
注释。在方法@EBean
中,可以修改prepareConnection(HttpURLConnection connection,String httpMethod)
HttpURLConnection
- 创建一个用
注释的接口,如上文所述,并设置实现@Rest
的类,该类是在注释ClientHttpRequestFactory
的@Rest
字段中创建的请求工厂