此GET端点在这里遇到了一些麻烦。由于某种原因,正在调用状态500 Internal Server Error,并且正文为空。
这是GET调用的代码:
@GetMapping
public List<TitulosPagar> getTitulosPagar() {
System.out.println("GET called");
List<TitulosPagar> titulos = titulosPagarService.pesquisar();
System.out.println(titulos);
return titulos;
titulosPagarService.pesquisar()返回带有titulosPagar完整列表的JpaRepository.findAll()。
sysoutPrint显示它获取由对象TitulosPagar制成的列表:
GET called
[br.com.lev.ficpagar.model.TitulosPagar@13d10944,br.com.lev.ficpagar.model.TitulosPagar@5a57aa65,br.com.lev.ficpagar.model.TitulosPagar@1ac0f72,br.com.lev.ficpagar.model.TitulosPagar@3a052abc]
但是在邮递员中,我得到了一个空的正文和500个内部服务器错误
邮递员控制台响应:
GET /ficpagar/titulospagar HTTP/1.1
Content-Type: application/json
User-Agent: PostmanRuntime/7.24.1
accept: */*
Cache-Control: no-cache
Postman-Token: b273167d-92d4-44e6-bea0-88c8b70af99e
Host: localhost:8080
accept-Encoding: gzip,deflate,be
Connection: keep-alive
HTTP/1.1 500 Internal Server Error
access-control-allow-origin: http://localhost:4200
access-Control-Allow-Credentials: true
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue,14 Apr 2020 20:31:03 GMT
Connection: close
,
curl --location --request GET 'localhost:8080/ficpagar/titulospagar' \
--header 'Content-Type: application/json' \
--data-raw ''
奇怪的是,此测试GET端点工作正常。
@GetMapping
public String test() {
return "Everything fine!";
}
和POST端点:
@PostMapping
public ResponseEntity<TitulosPagar> criar(@Valid @RequestBody TitulosPagar tituloPagar,HttpServletResponse response) {
tituloPagar = titulosPagarService.criar(tituloPagar);
URI uri = ServleturiComponentsBuilder.fromCurrentRequesturi().path("/{codigo}").buildAndExpand(tituloPagar.getId()).toUri();
response.setHeader("Location",uri.toASCIIString());
return ResponseEntity.created(uri).body(tituloPagar);
}
我在PostgreSQL中使用localServer。
这t seem to be a problem in the code. But I don
不知道,您知道这可能是错吗?