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

相关推荐
Flittly6 小时前
【雕虫大技】Agent 动态 Skill 供应链安全加固(二):执行隔离沙箱实战
java·spring boot·spring
沐言人生6 小时前
HelloAgentR工程手记1/100天——项目工作流搭建
spring boot·agent·vibecoding
云烟成雨TD7 小时前
Micrometer 系列【33】Spring Boot Micrometer Metrics 自动配置模块解析
spring boot·云原生·micrometer
用户31268748772010 小时前
接口太慢?Spring Boot 缓存体系 @Cacheable 全链路拆解
spring boot
snow@li10 小时前
SpringBoot:AOP日志切面全景梳理/原理+流程+实战+避坑
java·开发语言·spring boot
snow@li11 小时前
SpringBoot:全套生命周期全景详解/应用级+Bean级
java·spring boot·rpc
凤山老林1 天前
Spring Boot @Async 线上实战:从默认配置到生产级线程池治理
java·spring boot·后端
凤山老林1 天前
Spring Boot 定时任务进阶:动态 Cron 与集群防重实战
java·spring boot·后端·定时任务·集群定时任务
凤山老林1 天前
Spring Boot 配置管理实战:多环境隔离、加密与 Nacos 热更新避坑指南
java·spring boot·后端
凤山老林1 天前
可观测性落地:Spring Boot 3.x + Actuator + Prometheus + Grafana 监控体系搭建
spring boot·grafana·prometheus