Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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 Spring中的400错误请求错误_Java_Json_Spring_Rest - Fatal编程技术网

Java Spring中的400错误请求错误

Java Spring中的400错误请求错误,java,json,spring,rest,Java,Json,Spring,Rest,我发现了这个错误,知道是什么原因吗? 我试图发送一个DTO,它有一个扩展了抽象类的对象列表。我想这个问题可能是因为DTO中的列表,或者是因为抽象类中的子类 @Autowired private RestClient restClient; @Override public ReceiptDto create_TicketIdentifier_For_Sale(TicketSaleDto tiDto) throws ServiceException { RestTem

我发现了这个错误,知道是什么原因吗? 我试图发送一个DTO,它有一个扩展了抽象类的对象列表。我想这个问题可能是因为DTO中的列表,或者是因为抽象类中的子类

@Autowired
private RestClient restClient;


@Override
public ReceiptDto create_TicketIdentifier_For_Sale(TicketSaleDto tiDto)
        throws ServiceException {

    RestTemplate restTemplate = this.restClient.getRestTemplate();
    String url = this.restClient.createServiceUrl("/ticketIdentifier/");
    HttpHeaders headers = this.restClient.getHttpHeaders();
    //headers.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
    HttpEntity<TicketSaleDto> entity = new HttpEntity<>(tiDto, headers);

    ReceiptDto ti = null;
    try {
        ParameterizedTypeReference<ReceiptDto> ref = new ParameterizedTypeReference<ReceiptDto>() {};
        ResponseEntity<ReceiptDto> response = restTemplate.exchange(URI.create(url), HttpMethod.POST, entity, ref);
        ti = response.getBody();
        //  System.out.println(ti.getEntryDto().getReceiptDto().getCustomerDto().getLastname());
    } catch (RestClientException e) {
        e.getStackTrace();
        throw new ServiceException("Could not retrieve ticketIdentifiers: " + e.getMessage());
    }
    return ti;  
@Autowired
私人客户;
@凌驾
公开接收以创建用于销售的TicketIdentifier(TicketSaleDto tiDto)
抛出ServiceException{
RestTemplate RestTemplate=this.restClient.getRestTemplate();
字符串url=this.restClient.createServiceUrl(“/ticketIdentifier/”);
HttpHeaders=this.restClient.getHttpHeaders();
//headers.add(“内容类型”,MediaType.APPLICATION\u FORM\u URLENCODED\u值);
HttpEntity实体=新的HttpEntity(tiDto,标题);
ReceiptDto ti=null;
试一试{
ParameteredTypeReference ref=新的ParameteredTypeReference(){};
ResponseEntity response=restemplate.exchange(URI.create(url)、HttpMethod.POST、entity、ref);
ti=response.getBody();
//System.out.println(ti.getEntryDto().getReceiptDto().getCustomerDto().getLastname());
}捕获(RestClientException e){
e、 getStackTrace();
抛出新的ServiceException(“无法检索ticketIdentifiers:+e.getMessage());
}
返回ti;


2014-12-13T02:21:34867[JavaFX应用程序线程]调试http.wire-http-outing-0解决方案就在这里..一些子类的定义解决了我的问题。。

抽象类的子类导致问题。。。
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "HTTP/1.1 400 Bad Request[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Date: Sat, 13 Dec 2014 01:21:34 GMT[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Content-Type: text/html; charset=ISO-8859-1[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Cache-Control: must-revalidate,no-cache,no-store[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Content-Length: 316[\r][\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Server: Jetty(9.2.2.v20140723)[\r][\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "[\r][\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<html>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<head>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<title>Error 400 Bad Request</title>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "</head>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<body><h2>HTTP ERROR 400</h2>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<p>Problem accessing /ticketline/ticketIdentifier/. Reason:[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<pre>    Bad Request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "</body>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "</html>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << HTTP/1.1 400 Bad Request
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Date: Sat, 13 Dec 2014 01:21:34 GMT
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Content-Type: text/html; charset=ISO-8859-1
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Cache-Control: must-revalidate,no-cache,no-store
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Content-Length: 316
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Server: Jetty(9.2.2.v20140723)
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG execchain.MainClientExec - Connection can be kept alive indefinitely
2014-12-13T02:21:34,868 [JavaFX Application Thread] WARN  client.RestTemplate - POST request for "http://localhost:8080/ticketline/ticketIdentifier/" resulted in 400 (Bad Request); invoking error handler
2014-12-13T02:21:34,868 [JavaFX Application Thread] WARN  client.RestTemplate - POST request for "http://localhost:8080/ticketline/ticketIdentifier/" resulted in 400 (Bad Request); invoking error handler
2014-12-13T02:21:34,870 [JavaFX Application Thread] DEBUG conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://localhost:8080] can be kept alive indefinitely
2014-12-13T02:21:34,870 [JavaFX Application Thread] DEBUG conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://localhost:8080][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
2014-12-13T02:21:34,871 [JavaFX Application Thread] DEBUG controller.TicketingProcessController - Could not retrieve ticketIdentifiers: 400 Bad Request