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

相关推荐
爱吃羊的老虎7 小时前
【JAVA】python转java:Spring Boot 入门
java·spring boot·python
_qingche8 小时前
H2 数据库到 MySQL 数据迁移
java·数据库·spring boot·mysql·spring·重构·kotlin
码语智行11 小时前
系统启动时初始化数据功能分析
java·spring boot
invicinble11 小时前
推荐一下,遇到的几本比较好的书
spring boot
憧憬成为java架构高手的小白12 小时前
git工作流程简化版
java·spring boot·git
YDS82913 小时前
DeepSeek RAG&MCP + Agent智能体项目 —— 动态决策策略的接口对接
java·spring boot·ai·agent·spring ai·deepseek
淘源码A14 小时前
专科医院云HIS系统源码:技术栈包括SpringBoot、Angular、MySQL等
spring boot·后端·源码·云his·医院信息系统·医院his系统
小马爱打代码14 小时前
基于 SpringBoot 的微服务文件上传下载组件设计与实现
spring boot·后端
Java患者·16 小时前
Spring Boot 3 整合 Elasticsearch 8
spring boot·后端·elasticsearch