前后端不分离,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标签值为 datai.xxx

java 后端接口

POST 接收对象的定义

java 复制代码
List<XxxxDTO> data

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

相关推荐
热心市民lcj4 小时前
Spring Boot 整合 Caffeine 本地缓存实战
spring boot·后端·缓存
天丁o5 小时前
Spring Boot + MyBatis Plus 考勤日报统计报表:打卡记录聚合、异常分类和明细下钻 Demo
spring boot·mybatis plus·企业数字化·考勤系统·报表统计
Devin~Y6 小时前
从本地生活电商到 AI RAG:互联网大厂 Java 面试场景完整实战
java·spring boot·redis·elasticsearch·spring cloud·kafka·rag
米码收割机6 小时前
SA508-3钢回火焊道焊接温度场数值模拟(模拟图+论文)
spring boot·express·宠物
米码收割机7 小时前
【项目】spring boot+vue3 宠物领养系统(源码+文档)【独一无二】
java·spring boot·宠物
momo17 小时前
Java+WebAI黑马知识点
java·spring boot·mybatis
就改了1 天前
Mybatis快速入门大全(详细版)
java·spring boot·mybatis
Listen·Rain1 天前
Spring Boot 整合 JWT:从入门到源码原理深度解析
java·spring boot·后端
自强的小白1 天前
重点Springboot原理(起步原理和自动配置的两个实现方案)!
spring boot·spring
罗超驿1 天前
3.SpringBoot快速上手:从零搭建你的第一个Web应用
前端·spring boot·后端