Pass bi-dimensional javascript arrays to spring MVC controller wthout ajax -
in javascript declared bi-dimensional array:
<script> var values0=[["001", "2015-09-01", "100", "s"],["002", "2015-09-02", "200", "s"]]; </script>
in form have hidden field:
<input type="hidden" id="hrdscvalues0" name="values" >
this code of submit button:
$('#hrdscvalues0').val(values0); $( "#mymodelform" ).submit();
in spring mvc model have field "values":
private string[] values;
in controller receive 2 lines of javascript array in same dimension:
if in model create bidimensional array:
private string[][] values;
this have in controller:
how can pass bi-dimensional array in javascript model of spring mvc controller?
thanks.
edit:
this form:
<form:form id="mymodelform" action="/submitmymodel" method="post" commandname="mymodel" > <input type="hidden" id="hrdscvalues0" name="values" > [...]
in controller there request mapping:
@requestmapping(value = "/submitmymodel", method = requestmethod.post) public string submitmymodel(httpsession session, @modelattribute("mymodel")mymodel mymodel, model model) { [...]
and model:
public class mymodel { private string[] values; [...] public string[] getvalues() { return values; } public void setvalues(string[] values) { this.values = values; } }
and second version of model:
public class mymodel { private string[][] values; [...] public string[][] getvalues() { return values; } public void setvalues(string[][] values) { this.values = values; } }
Comments
Post a Comment