У меня есть базовое приложение SpringBoot.используя Spring Initializer, JPA, встроенный Tomcat, шаблонизатор Thymeleaf и пакет в качестве исполняемого файла JAR.Я определил этот метод Rest для обновления пользователя
@PutMapping(path = "/api/users/{id}",
consumes = "application/json",
produces = "application/json")
public ResponseEntity<User> updateUser
(HttpServletRequest request,
@PathVariable long id,
User user) {
System.out.println(user);
saveUser (user)
return ResponseEntity.ok(user);
}
Я вызываю этот метод из консоли, используя
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIazUxMiJ9.eyJzdWIiOiJyaWNhcmQub2xsZUBnbWFpbC5jb20iLCJleHAiOjE1MjgxMTM3NTIsImlhdCI6MTUyNzUwODk1Mn0.QdxabtU1U87pYvyTstT1EG3E6uVpLo2mXCF0FF8iD6acKoAXKl_A0-eV_GrpOFg5FF1qR6B7llI5_USJL85YTQ" -d {"id":1,"username":"pere.peris@gmail.com","email":"pere.peris@gmail.com","firstName”:”Pere”,”lastName”:”PERIS”,”country”:”CAT”,”enabled":true} "http://127.0.0.1:2233/elcor/api/users/1"
, но то, что я вижу в консоли, действительно странно
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/gmail/">here</A>.
</BODY></HTML>
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/gmail/">here</A>.
</BODY></HTML>
curl: (3) Port number ended with 'R'
curl: (3) Port number ended with 'P'
curl: (3) Port number ended with 'E'
curl: (3) Port number ended with 'i'
curl: (3) Port number ended with 'a'
curl: (3) Port number ended with 'm'
curl: (3) Port number ended with 'm'
curl: (3) Port number ended with 'c'
curl: (3) Port number ended with 't'
curl: (3) Port number ended with 't'
curl: (3) Port number ended with 't'
curl: (3) Port number ended with 't'
curl: (3) [globbing] bad range specification in column 14
curl: (3) Port number ended with 't'
{"id":1,...."enabled":false}