Please take a look at codes below. Four text boxes are displayed.
If I input "1" and "2" to former text-boxes, these are binded as comma-separated "1,2" as I expected.
However, if I input "2001/01/01" and "2001/01/02" in rest of two-boxes are binded "2001/01/01". "2001/01/01" is only binded surprisingly. First parameter seems having a priority to bind.
I want to know where is defined the specifications(HTTP or SpringMVC or ...?) about that in order to understand deeply and accurately. Can someone help me?
Form
public class SampleForm {
private String name;
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
JSP
<form:form modelAttribute="form" method="post">
<form:input path="name" />
<form:input path="name" />
<form:input path="date" />
<form:input path="date" />
<p>
<input type="submit" name="register" value="register" />
</p>
</form:form>
It's logical. Multiple strings can be represented as one String
by being comma-separated. Multiple Date
objects can't be represented as one Date
object.
You can try using String[]
and Date[]
instead.
private List<Date> date= new ArrayList<Date>();
public List<Date> getDate() {
return date;
}
public void setDate(List<Date> date) {
this.date= date;
}
It will solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With