Discuss / Java / 用Fiddle去发post request出错

用Fiddle去发post request出错

Topic source

错误是这样的:

2020-10-09 06:42:09 WARN  o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json' not supported]

我没有明白,明明是有@RestController了呀

win10环境命令行这样:

curl -v -H "Content-Type:application/json" -d '{"email":"bob@example.com","password":"bob123"}' http://localhost:8080/api/signin

*   Trying ::1...

* TCP_NODELAY set

* Connected to localhost (::1) port 8080 (#0)

> POST /api/signin HTTP/1.1

> Host: localhost:8080

> User-Agent: curl/7.55.1

> Accept: */*

> Content-Type:application/json

> Content-Length: 41

>

* upload completely sent off: 41 out of 41 bytes

< HTTP/1.1 415

< Content-Type: text/html;charset=utf-8

< Content-Language: en

< Content-Length: 1087

< Date: Thu, 08 Oct 2020 19:49:01 GMT

<

<!doctype html><html lang="en"><head><title>HTTP Status 415 – Unsupported Media Type</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 415 – Unsupported Media Type</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.</p><hr class="line" /><h3>Apache Tomcat/9.0.26</h3></body></html>* Connection #0 to host localhost left intact

谢谢

我错了。我找到错误了。我项目里面不知道什么时候在一个不合适的地方建了一个pom.xml 我的jackson加到那个里面了。等于我其实没装上这个。

装上了以后就好了。


  • 1

Reply