spring mvc 后台直接接受bean和list

1.转为bean
前台页面
<form method="post" class="x-layout-center " id="theform">
		<div class="archives-form" style="text-align: center;">
			<h4 class="text-center archives-title">新增试题</h4>
			<table border="0" align="center" width="100%" class="archives-table" style="margin-top: 20px;">
				<tr>
					<td style="width: 100px; text-align: center;">
						<label class="x-form-label">名    称</label>
						<span style="color: red;">*</span>
					</td>
					<td>
						<input class="x-form-text form-control" id="topicName" name="topicName" placeholder="请输入试题名称" x-form-validate="isNull<试题名称不能为空>;max[30]<试题名称长度不能超过30个字符>;"/>
					</td>
				</tr>
				<tr>
					<td style="width: 100px; text-align: center;">
						<label class="x-form-label">题库组</label>
						<span style="color: red;">*</span>
					</td>
					<td>
						<div class="input-group" id="customer" style="width: 100%;">
		            		<input type="hidden" id="topicGroupName" name="topicGroupName"/>
		            		<div class="x-form-combobox-group" x-form-validate="selectNum[1]<请选择或新增题库>" style="width: 100%;">
								<input class="x-form-text" id="topicGroupId" name="topicGroupId" placeholder="请选择或新增题库" />
							</div>
							<div class="input-group-addon">
								<span class="fa fa-book" style="cursor: pointer; border-left: 0px;" οnclick="addTopicGroup()">  新增</span>
							</div>
						</div>
					</td>
				</tr>
 			</table>
 			<button type="button" class="btn btn-success" οnclick="onSave()" style="margin-top: 25px; width: 120px;">保      存</button>
 		</div>
	</form>
js
var data = formValidate.serializeObject("#theform");//注意,这里序列化表单,表单元素的name要与实体bean对应。
					$.post(url, data, function(result) {
						if (result.success == true) {
							//成功
							}, "x-panel-success");
						} else {
							//失败
						}
					}, "json");

后台代码

@RequestMapping("/deleteTopicFlat.do")
	@ResponseBody
	public JsonMsg deleteTopicFlat(HttpServletResponse response, HttpServletRequest request,
		@ModelAttribute Bean bean) {
		
	}

2. 转为list

注意,转为list,则需要前台传的是一个数组,后台则直接用List接收,如下

后台接收

@RequestMapping("/aaa")
@ResponseBody
public Object aaa(@RequestBody List<SysUser> syss){
SysDepart model= sysDepartService.findById(guid);
return model;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值