Spring MVC: @RequestMapping: How to catch Map parameter? -


i have controller method processing form submitting:

@requestmapping(method = {requestmethod.post})     public string submitform(...){...} 

but, have got new test case:

if form has parameter productdata call controller method submitformwithproductdata. , facing difficulties this, because productdata map. on site productdata field in form tag looks like:

<input type="text" name="productdata['param1']"> <input type="text" name="productdata['param2']"> 

and don't know, how create right @requestmapping annotation submitformwithproductdata method.

i have tried:

@requestmapping(method = {requestmethod.post}, params="productdata") 

and

@requestmapping(method = {requestmethod.post}, params="productdata[]") 

but didn't success.

productdata has property of model object.

public class formmodel {     private map<string,string> productdata = ...;     ... } 

according have create handler method that:

@requestmapping(....) public string submitformwithproductdata(formmodel formmodel) {   .... } 

spring automatically bind productdata parameters according property in formmodel object.

but don't know why want handle differently. add hidden input field productdatasubmitted , add following handler:

@requestmapping(method = {requestmethod.post}, params="productdatasubmitted") 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -