I have the controller method for processing form submitting:
@RequestMapping(method = {RequestMethod.POST})
public String submitForm(...){...}
But, I have got a new test case:
If Form has parameter ProductData
call controller method submitFormWithProductData
. and I am facing difficulties with this, because ProductData
is a Map
. On Site ProductData
field in form tag looks like:
<input type="text" name="productData['param1']">
<input type="text" name="productData['param2']">
And I don't know, how to create right @RequestMapping
annotation for submitFormWithProductData
method.
I have tried:
@RequestMapping(method = {RequestMethod.POST}, params="productData")
and
@RequestMapping(method = {RequestMethod.POST}, params="productData[]")
but I didn't get success.
Use
@RequestBody Map<String,String> productData
as argument int the controller method.Here is a Blog and Read more...
For example:
productData
has to be a property of a model object.according to this you have to create a handler method like that:
Spring will automatically bind the productData parameters to the according property in the
FormModel
object.But I don't know why you want to handle it differently. You could add a hidden input field
productDataSubmitted
and add the following handler: