前后端不分离,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 的命名

相关推荐
全干engineer5 小时前
Spring Boot 实现主表+明细表 Excel 导出(EasyPOI 实战)
java·spring boot·后端·excel·easypoi·excel导出
a_Dragon16 小时前
Spring Boot多环境开发-Profiles
java·spring boot·后端·intellij-idea
ChinaRainbowSea6 小时前
补充:问题:CORS ,前后端访问跨域问题
java·spring boot·后端·spring
全栈凯哥10 小时前
02.SpringBoot常用Utils工具类详解
java·spring boot·后端
RainbowSea12 小时前
跨域问题(Allow CORS)解决(3 种方法)
java·spring boot·后端
RainbowSea12 小时前
问题 1:MyBatis-plus-3.5.9 的分页功能修复
java·spring boot·mybatis
sniper_fandc14 小时前
SpringBoot系列—入门
java·spring boot·后端
Albert Edison19 小时前
【最新版】IntelliJ IDEA 2025 创建 SpringBoot 项目
java·spring boot·intellij-idea
六毛的毛1 天前
Springboot开发常见注解一览
java·spring boot·后端
开开心心就好1 天前
免费PDF处理软件,支持多种操作
运维·服务器·前端·spring boot·智能手机·pdf·电脑