首先后台接收对象不能是List,下面写法会说找不到List的get,set方法

@RequestMapping("/submitForm")
	public String submitForm(List<User> list){
		return "";
	}

那如何后台接收呢,需要创建一个接收对象,将List放里面即可

public class Data{
	private List<User> list;//User里面有用户uId和uName
	private String  paId;//部门id
	//set  get方法
}
@RequestMapping("/submitForm")
	public String submitForm(Data data){
		return "";
	}

以上后台才设置好;

前台呢:如下,页面初始化可以动态获取,提交表单时候后台用Data类来接收,会封装到list里面

<div th:each="user,userStatus:${data.list}">
		<input type="checkbox" th:field="*{list[__${userStatus.index}__].uId}"
		 th:text="${'用户名:&nbsp;&nbsp;&nbsp;'+user.uName}"  th:value="${user.uId}">
	</div>	

 

Logo

加入社区!打开量化的大门,首批课程上线啦!

更多推荐