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

相关推荐
程序员晓琪12 小时前
约定大于配置:基于 Java 包名自动生成 API 版本路由的最佳实践
java·spring boot·后端
Flittly12 小时前
【AgentScope Java新手村系列】(11)中断与恢复
java·spring boot·spring
用户3521802454752 天前
🎆从 Prompt 到 Skill:让 Spring AI Agent 学会"装新技能"
人工智能·spring boot·ai编程
用户3521802454754 天前
当 Prompt 学会"热更新":Spring Boot × Nacos3 AI 实战
java·spring boot·ai编程
昵称为空C5 天前
手撸一个动态 SQL 执行引擎:不重启服务,在线增删改查任意数据库
spring boot·后端
霸道流氓气质5 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
于先生吖6 天前
SpringBoot对接大模型开发AI命理测算系统:八字排盘与AI解析接口源码全解
人工智能·spring boot·后端
Flittly6 天前
【AgentScope Java新手村系列】(10)实战-多Agent天气助手
java·spring boot·spring
星落zx6 天前
Spring Boot 多模型集成:优雅调用全球主流大模型
人工智能·spring boot·chatgpt