java 不支持方法“GET”,org.springframework.Web.HttpRequestMethodNotSupportedException:[关闭]

qoefvg9y  于 2023-04-28  发布在  Java
关注(0)|答案(1)|浏览(131)

**关闭。**此题需要debugging details。目前不接受答复。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答这个问题。
54分钟前关闭
Improve this question

@RestController
public class userController {
    
    @Autowired
    userRepo Userrepo;
    
    @PostMapping("/user1")
    public userModel createUser(@RequestBody userModel user)
    {
        user.setUserId(111);
        user.setUserName("sury");
        user.setUserEmail("sury@gmail.com");
        user.setUserPass("LeoLeo");
    
        return Userrepo.save(user);
    }

我试图将数据存储在数据库中,但它显示GET不支持错误。

hs1rzwqc

hs1rzwqc1#

您使用了注解@PostMapping,该注解用于将请求与POST方法Map,您尝试使用GET方法使用请求访问此路径,尝试使用POST方法使用请求,或者切换到注解@GetMapping

相关问题