@RestController
@RequestMapping(value="/uri",produces = "application/json",
consumes="application/json")
public class VisitorService {
VisitorDAO vis=new VisitorDAO();
@RequestMapping(value = "/ex" ,method = RequestMethod.POST)
public String showDetails(@RequestBody VisitorDTO visitor){
vis.addVisitorEntry(visitor);
return "success"+visitor;
}}
以上是我的休息服务。每当我使用带有以下 JSON 的 URL 发布帖子时,
{
"phoneNumber" : 188892,
"name" : "kikiki" ,
"email" : "loa@gmail.com",
"purpose" : "Business",
"hostName" : "sjs S Murthy"
}
我得到 HTTP 状态 415 - 不支持的媒体类型。为什么会这样?