解决springboot中只支持get请求,无法支持post请求
报错信息如下: 405
相关类如下:
@RestController
@RequestMapping
public class HttpServiceController {@Autowiredprivate HttpSecretReport httpSecretReport;@Autowiredprivate HttpSecretRecording httpSecretRecording;@PostMapping(value="/secret_report", produces="application/json;charset=UTF-8")@ResponseBodypublic Object getCallRecordBySecretReport1(@RequestBody String requestBody){return httpSecretReport.dealHttpSecretReport(HttpMethodNameEnum.HTTP_SECRET_REPORT_HOME_DISPATCH.code,requestBody);}
}
解决办法:@RequestMapping
增加post方法支持 @RequestMapping(value = "/call_record",method = {RequestMethod.GET,RequestMethod.POST})
@RestController
@RequestMapping(value = "/call_record",method = {RequestMethod.GET,RequestMethod.POST})
public class HttpServiceController {@Autowiredprivate HttpSecretReport httpSecretReport;@Autowiredprivate HttpSecretRecording httpSecretRecording;@PostMapping(value="/secret_report", produces="application/json;charset=UTF-8")@ResponseBodypublic Object getCallRecordBySecretReport1(@RequestBody String requestBody){return httpSecretReport.dealHttpSecretReport(HttpMethodNameEnum.HTTP_SECRET_REPORT_HOME_DISPATCH.code,requestBody);}
}
完美解决