AH02429:响应标头名称'record Created - '包含无效字符,中止请求

时间:2017-09-27 13:18:24

标签: linux spring apache api http-headers

我已经创建了一个基本身份验证的restful api,并且适用于mi IDE和Tomcat,我已经使用Postman进行过测试。但是当我将它部署到linux服务器时,我在error.log中遇到以下错误:

- AH02429: Response header name 'record Created  - ' contains invalid characters,   aborting request

我不明白为什么会出现此错误,因为这在部署之前运行良好。 我需要配置服务器吗? 请帮助。

我的控制器

@RequestMapping(value={"/record/add/"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, produces={"application/json"})
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) {
    HttpHeaders headers = new HttpHeaders();
    if (employee == null) {
        return new ResponseEntity(HttpStatus.BAD_REQUEST);
    }
    employeeService.createEmployee(employee);
    headers.add("record Created  - ", String.valueOf(employee.getId()));
    return new ResponseEntity(employee, headers, HttpStatus.CREATED);
}

当我尝试使用邮递员插入/创建记录时:

{ "id": 1, "surname": "Flores", "address1": "igle", "town": "campo", "postcode": "g", "c_b_name": "Charles", "b_event": "Chavan" }

我有以下错误:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
    <title>500 Internal Server Error</title>
</head>
<body>
    <h1>Internal Server Error</h1>
    <p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
    <p>Please contact the server administrator at 
webmaster@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
    <p>More information about this error may be available
in the server error log.</p>
    <p>Additionally, a 500 Internal Server Error
error was encountered while trying to use an ErrorDocument to handle the request.</p>
    <hr>
    <address>Apache/2.4.10 (Debian) Server at xxxxxxxx.com Port 80</address>
</body>
</html>

在服务器error.log中,我有以下错误:

Response header name 'record Created  - ' contains invalid characters, aborting request

1 个答案:

答案 0 :(得分:0)

我通过从控制器中删除httpHeaders找到了解决方案。