You can bind the request parameters when the bean property is in list format with the following code.
<body>
	<form action="/sample/bean" method="post">
		<table>
			<tr>
				<td>Input 1:price:</td>
				<td><input type="text" name="sampleBean.childBean[0].price"></td>
				<td>Input 1:unit:</td>
				<td><input type="text" name="sampleBean.childBean[0].unit"></td>
			</tr>
			<tr>
				<td>Input 2:price:</td>
				<td><input type="text" name="sampleBean.childBean[1].price"></td>
				<td>Input 2:unit:</td>
				<td><input type="text" name="sampleBean.childBean[1].unit"></td>
			</tr>
		</table>
	</form>
</body>
@Controller
public class SampleController {
	@RequestMapping(value="/sample/bean", method=RequestMethod.POST)
	public String goUserCreateErrorPage(SampleBean sampleBean) {
		return "sample";
	}
}
public class SampleBean {
  private String childBeanUnit;
  private List<SampleChildBean> childBean;
}
※getter,setter is abbreviation
public class SampleChildBean {
	private String price;
	private String unit;
}
※getter,setter is abbreviation
In this case, there is a point in how to define the name attribute of input. If you explain one by one, Explanation 1: Argument name of the binding target specified in the argument of @RequestMapping method on the Controller side Explanation 2: Specify the property name defined in the class of the argument to be bound. Since it is a list, specify the index number as well. Explanation 3: Finally, specify the property of the property class specified in Explanation 2 (is it complicated?)
<input type="text" name="sampleBean.childBean[0].price">
Commentary 1 Commentary 2 Commentary 3
It's good to write it before I forget it, but the explanation is not good enough. Let's think of a better explanation when we have time, lol
Recommended Posts