我收到“服务器在处理请求时遇到错误。”错误时尝试返回Iterable&通过ResponseEntity页面结果。自从我升级到 Spring Web MVC 4.2.4 以来,我遇到了这个问题。
My Spring WEB MVC版本:
示例代码(从Elasticsearch获取数据):
@RequestMapping(value = "/user/{usernamesearchstring}", method = RequestMethod.POST)
public ResponseEntity<Iterable<User>> searchUser(@PathVariable("userNameSearchString") String userNameSearchString) {
QueryBuilder builder = QueryBuilders.prefixQuery("userName", userNameSearchString);
Iterable<User> user = userElasticsearchRepository.search(builder);
HttpHeaders headers = new HttpHeaders();
return new ResponseEntity<Iterable<User>>(user, headers, HttpStatus.OK);
}
注意: