能够命中get方法端点但无法命中POST方法

时间:2017-01-02 11:00:17

标签: java spring-boot spring-restcontroller spring-rest

以下是我的代码

@RestController
@RequestMapping(value="/users")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value ="/registration",method = RequestMethod.POST)
    public void addUser(@RequestBody @Valid UserDTO userDTO) {
        System.out.println("from Post");
        userService.saveUser(userDTO);
    }

    @RequestMapping(value = "/dashboard/getUserDetails", method = RequestMethod.GET)
    public List<UserDTO> getUsers() {
        System.out.println("inside controller");
        return userService.getUsers();
    }}

在上面的代码中,当我试图让get endpoint工作时,当我试图点击POST端点时它会抛出404.

请帮助我解决问题

0 个答案:

没有答案