Http Post request with content type application/x-www-form-urlencoded not working in Spring

后端 未结 7 1648
逝去的感伤
逝去的感伤 2020-11-27 06:19

Am new to spring currently am trying to do HTTP POST request application/x-www-form-url encoded but when i keep this in my headers then spring not recognizing it an

7条回答
  •  星月不相逢
    2020-11-27 07:06

    Remove @ResponseBody annotation from your use parameters in method. Like this;

       @Autowired
        ProjectService projectService;
    
        @RequestMapping(path = "/add", method = RequestMethod.POST)
        public ResponseEntity createNewProject(Project newProject){
            Project project = projectService.save(newProject);
    
            return new ResponseEntity(project,HttpStatus.CREATED);
        }
    

提交回复
热议问题