Java 通过http.get请求传递正文

Java 通过http.get请求传递正文,java,angular,spring-boot,Java,Angular,Spring Boot,我在AngularIO中有一个应用程序,它是Java服务的客户机。 我有一个搜索,我想通过许多搜索条件。然后我为它创建了一个对象 export class CriteriosPesquisa{ public opcaoSelecionada: string; public diaDe: Date; public diaAte: Date; public numNfe: string; } 当我进行搜索时,我将对象传递到请购单Get的正文中。(我将在一个网格中显示

我在AngularIO中有一个应用程序,它是Java服务的客户机。 我有一个搜索,我想通过许多搜索条件。然后我为它创建了一个对象

export class CriteriosPesquisa{
    public opcaoSelecionada: string;
    public diaDe: Date;
    public diaAte: Date;
    public numNfe: string;
}
当我进行搜索时,我将对象传递到请购单Get的正文中。(我将在一个网格中显示结果)我的问题很明显是因为我使用的是带有GET的body

public getNfes(criterios: CriteriosPesquisa): Observable<Array<Nfe>>{
    const myHeaders = new Headers();
    myHeaders.append('Content-Type', 'application/json');
    // const myParams = new URLSearchParams();
    // myParams.append('criterios', criterios);
    const options = new RequestOptions({ headers: myHeaders, /*search: myParams,*/ body: JSON.stringify(criterios) });

    return this._http.request(`${URL_API}nfes`, options)
      .map(response => {
        return response.json();
      });
  }
public getNfes(criterios:CriteriosPesquisa):可观察{
const myHeaders=新的头();
append('Content-Type','application/json');
//const myParams=新的URLSearchParams();
//myParams.append('criterios',criterios);
const options=newrequestoptions({headers:myHeaders,/*search:myParams,*/body:JSON.stringify(criterios)});
返回此.http.request(`${URL\u API}nfes`,选项)
.map(响应=>{
返回response.json();
});
}
2018-05-12 23:34:19.740警告1076---[nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver:无法读取HTTP 信息: org.springframework.http.converter.httpMessageNodeTableException: 缺少必需的请求正文:public java.util.List br.com.minhasCompras.service.NfeService.buscarNfe(br.com.minhasCompras.eo.Criterios)

@RequestMapping(value=“/nfes”)
公共列表buscarNfe(@RequestBody-Criterios-Criterios){
System.out.println(criterios.getOpcaoSelecionada());
System.out.println(criterios.getNumNfe());
System.out.println(criterios.getDiaAte());
System.out.println(criterios.getDiaDe());
返回新的ArrayList();
}

你知道这件事吗?如何使用GET为客户端传递对象?

HTTP GET的服务器语义是忽略它(读取),可能是Spring决定忽略请求体,因此无法读取“必需”的请求体。使用POST方法通过请求体是更好的最佳实践,是什么阻碍了您这样做?好的,我理解您。我会听从你的建议。我会用邮局。谢谢
@RequestMapping(value = "/nfes")
public List<Nfe> buscarNfe(@RequestBody Criterios criterios){

    System.out.println(criterios.getOpcaoSelecionada());
    System.out.println(criterios.getNumNfe());
    System.out.println(criterios.getDiaAte());
    System.out.println(criterios.getDiaDe());

    return new ArrayList<Nfe>();
}