解决springboot中只支持get请求,无法支持post请求
报错信息如下: 405
相关类如下:
@RestController
@RequestMapping
public class HttpServiceController {
@Autowired
private HttpSecretReport httpSecretReport;
@Autowired
private HttpSecretRecording httpSecretRecording;
@PostMapping(value="/secret_report", produces="application/json;charset=UTF-8")
@ResponseBody
public 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 {
@Autowired
private HttpSecretReport httpSecretReport;
@Autowired
private HttpSecretRecording httpSecretRecording;
@PostMapping(value="/secret_report", produces="application/json;charset=UTF-8")
@ResponseBody
public Object getCallRecordBySecretReport1(@RequestBody String requestBody){
return httpSecretReport.dealHttpSecretReport(HttpMethodNameEnum.HTTP_SECRET_REPORT_HOME_DISPATCH.code,requestBody);
}
}
完美解决
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://lebron.blog.csdn.net/article/details/124832364
内容来源于网络,如有侵权,请联系作者删除!