我正在使用 Spring boot 开发应用程序。我尝试使用所有表示动词,如 GET、POST、DELETE,它们都工作正常。通过使用 PUT 方法,它在 spring boot 中不支持。我是否需要添加任何新配置。
Put 方法仅适用于没有任何参数的请求。如果我添加任何查询参数或表单数据,它就不起作用。请任何专家帮助我解决这个问题。
@RequestMapping("/student/info")
@RequestMapping(method = RequestMethod.PUT)
public @ResponseBody String updateStudent(@RequestParam(value = "stdName")String stdName){
LOG.info(stdName);
return "ok";
}
Request method 'PUT' not supported
请您参考如下方法:
这段代码可以正常工作。您必须在类级别或函数中指定请求映射 水平。
@RequestMapping(value = "/student/info", method = RequestMethod.PUT)
public @ResponseBody String updateStudent(@RequestBody Student student){
LOG.info(student.toString());
return "ok";
}