前后端不分离,form前端表单提交,springboot后端list接收

前端JS

javascript 复制代码
var data= $("#form-xxx").serializeArray();
var config = {
	url: url,
	type: "post",
	dataType: "json",
	data: data,
	beforeSend: function () {
		$.modal.loading("正在处理中,请稍后...");
	},
	success: function(result) {
		if (typeof callback == "function") {
			callback(result);
		}
		$.operate.successTabCallback(result);
	}
};
 $.ajax(config)

前端 thymeleaf的html

html 复制代码
<form th:each="tb,tbState : ${tables}">
<input
th:id="${#strings.concat('tableName',tbState.index)}"
th:name="${#strings.concat('data[',tbState.index,'].tableName')}"
th:value="${tb.tableName}"
type="hidden"  />

</form>

form里循环生成 input

name标签值为 data[i].xxx

java 后端接口

POST 接收对象的定义

java 复制代码
List<XxxxDTO> data

XxxxDTO 的属性对应单次input循环的name 的命名

相关推荐
czlczl2002092523 分钟前
SpringBoot中web请求路径匹配的两种风格
java·前端·spring boot
Q_Q51100828528 分钟前
python+django/flask医药垃圾分类管理系统
spring boot·python·django·flask·node.js·php
q_19132846951 小时前
基于SpringBoot2+Vue2+uniapp的考研社区论坛网站及小程序
java·vue.js·spring boot·后端·小程序·uni-app·毕业设计
Q_Q5110082851 小时前
python+django/flask创新型产品提前购系统
spring boot·python·django·flask·node.js·php
码界奇点1 小时前
Spring Boot 全面指南从入门到精通构建高效Java应用的完整路径
java·spring boot·后端·微服务
她说..1 小时前
Spring Boot中读取配置文件的5种方式汇总
java·spring boot·后端·spring·springboot
Q_Q19632884752 小时前
python+django/flask+vue的基于协同过滤算法的体育商品推荐系统
spring boot·python·django·flask·node.js·php
坚定信念,勇往无前2 小时前
springboot +mongodb游标分页,性能好。前端存储游标历史
前端·spring boot·mongodb
s***P9822 小时前
Spring Boot实时推送技术详解:三个经典案例
spring boot·后端·状态模式
java干货2 小时前
优雅停机!Spring Boot 应用如何使用 Hook 线程完成“身后事”?
java·spring boot·后端