Java Spring Boot中没有对修补程序方法的响应
我正在尝试创建一个RESTAPI。GET&POST方法按预期工作。然而,对于补丁方法,我得到了意想不到的行为。下面是我的控制器代码Java Spring Boot中没有对修补程序方法的响应,java,spring-boot,rest,Java,Spring Boot,Rest,我正在尝试创建一个RESTAPI。GET&POST方法按预期工作。然而,对于补丁方法,我得到了意想不到的行为。下面是我的控制器代码 import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PostMapping; impo
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("v1/test")
public class TestController {
@GetMapping(value = "get-test")
public String getTest(){
return "Get Success";
}
@PatchMapping(value = "patch-test")
public String patchTest(){
return "Patch Success";
}
@PostMapping(value = "post-test")
public String postTest(){
return "Post Success";
}
}
当我点击PATCH method loader时,它一直在旋转&没有得到任何响应。
如果我在GET或POST之后点击补丁,我会得到补丁方法之前的API响应。
同样的代码也适用于其他机器。我尝试过IntelliJ和Eclipse,行为是一样的。从多个客户(如postman&curl)处尝试了此功能。附加屏幕截图。这是以前的工作。没有做任何更改&现在它不工作了
@RequestMapping(value = "v1/test")
@PatchMapping(path = "/patch-test")
2-您应该在patch参数中写入路径而不是值,并将/character放在url之前,如下所示:
@RequestMapping(value = "v1/test")
@PatchMapping(path = "/patch-test")
试着用简单的方法,这在一秒钟内对我有效 试试下面的代码
@PatchMapping("/patchtest")
public String patchtest(){
return "Patch Success";
}
另外,别忘了提到@RestController annotation这不是问题所在。我的请求正在到达patchTest()方法。问题是我没有得到回应