One: After testing, it is found that if the following Controller ( @RequestBody ) is used, the request body of the front-end POST can only be JSON . If it is form-data, X-www-form-urlencoded or XML, it will report 415 Unsupported Media Type error
@RequestMapping(value = "/users", method = RequestMethod.POST ) public String addUser(@RequestBody User user, HttpServletRequest request) { userService.addUser(user); return "OK"; }
Two: If you want to accept form-data / X-www-form-urlencoded : You can use HttpServletRequest to get parameters using the following methods.
request.getParameterNames()
request.getParameter("AA")
request.getParameterMap()
@RequestMapping(value = "/users/new", method = RequestMethod.POST ) public String addUser( HttpServletRequest request) { System.out.println(request.getQueryString()); return "OK"; }