I typically retrieve POST parameters like the following:
@RequestMapping(method = RequestMethod.POST)
public ModelAndView create(
@RequestParam(value = "first_name", required = false) String firstName,
HttpServletRequest request
) {
But what if some parameters are in the URL like http://example.com/post/path?last_name=Smith
? Is Spring supposed to grab all the parameters from both the URL and the POST data when RequestMapping
is POST?
Basically, Facebook sends a signed_request parameter via POST and other parameters like request_ids at the same time via URL parameters. I need to get both.
But what if some parameters are in the URL like http://example.com/post/path?last_name=Smith? Is Spring supposed to grab all the parameters from both the URL and the POST data when RequestMapping is POST?
Yes, spring will get all parameter values (in form and url) for a POST request. but in your case
@RequestParam(value = "first_name", required = false) String firstName,
will be null. Because in your url, the parameter name is last_name
. :D