Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java AndroidAnnotations 3.0@Rest_Java_Android_Android Annotations - Fatal编程技术网

Java AndroidAnnotations 3.0@Rest

Java AndroidAnnotations 3.0@Rest,java,android,android-annotations,Java,Android,Android Annotations,我正在尝试使用AndroidAnnotations访问RESTAPI。我的代码如下: public interface MyRestInterface { //for some reason it is not possible to specify MultiValueMap<String, Object> - //annotations produce invalid code @Post("/rest.api") public ResponseE

我正在尝试使用AndroidAnnotations访问RESTAPI。我的代码如下:

public interface MyRestInterface
{
    //for some reason it is not possible to specify MultiValueMap<String, Object> -
    //annotations produce invalid code
    @Post("/rest.api")
    public ResponseEntity<MyXMLResponse> makeRequest(MultiValueMap multiValueMap);
}
公共接口MyRestInterface
{
//由于某些原因,无法指定多值映射-
//注释产生无效代码
@Post(“/rest.api”)
公共响应生成请求(多值映射多值映射);
}
在AA版本2.7.1上,这产生了以下代码:

@Override
public ResponseEntity<TravelAbroadIssuePolicyXmlResponse> makeRequest(MultiValueMap multiValueMap) 
{
    HttpHeaders httpHeaders = new HttpHeaders();
    HttpEntity<MultiValueMap> requestEntity = new  HttpEntity<MultiValueMap>(multiValueMap, httpHeaders);
    return restTemplate.exchange(rootUrl.concat("/rest.api"), HttpMethod.POST, requestEntity, MyXMLResponse.class);
}
@覆盖
公共响应生成请求(多值映射多值映射)
{
HttpHeaders HttpHeaders=新的HttpHeaders();
HttpEntity requestEntity=新的HttpEntity(多值映射,httpHeaders);
返回restemplate.exchange(rootUrl.concat(“/rest.api”)、HttpMethod.POST、requestEntity、MyXMLResponse.class);
}
这是按预期工作的,特别是将多值映射值放入请求体中。 然而,在AA 3.0中,它产生了以下结果:

@Override
public ResponseEntity<MyXMLResponse> makeRequest(MultiValueMap multiValueMap) 
{
    HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(multiValueMap);
    ... (try to make a request and intercept errors)
}
@覆盖
公共响应生成请求(多值映射多值映射)
{
HttpEntity requestEntity=新的HttpEntity(多值映射);
…(尝试发出请求并拦截错误)
}
请注意,不再涉及HTTP头。奇怪的是,这会导致多值映射值被放入请求头中,使主体为空。
目前,我求助于使用AA2.7.1。在AA 3.0+上有正确的方法吗?

当您使用
多值映射
类时,我想您的rest客户端必须调用表单HTTP ws。因此,您必须使用
FormHttpMessageConverter
作为请求的转换器。你能确认你用的是这个吗

另外,您应该更新到AA3.0.1,它解决了泛型的使用问题