Android Annotation 3.1如何在resttemplate中注入requestfactory

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

如何将其注入RestTemplate android注释

  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
    请求工厂
    字段中创建的
connection.addRequestProperty(“缓存控制”,“仅当缓存时”);为什么在将此添加到PrepareConnection时出现服务器错误@路易