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

相关推荐
霸道流氓气质15 小时前
SpringBoot中通用工具类库(Utils)封装与使用实践
spring boot·后端·python
whyfail19 小时前
前端学 Spring Boot(2):一次点击,如何穿过整个后端?
前端·spring boot·后端
乔伊酱20 小时前
我被列表查询折磨了 7 年,直到有一天我发现它不是 ORM 的事!
spring boot·graphql
霸道流氓气质1 天前
SpringBoot中基于 AES-GCM + KMS 密钥管理的数据加解密 Starter 实践
java·数据库·spring boot
乐观的Terry1 天前
8、发布系统-完整流水线的核心
java·spring boot·spring·spring cloud
万亿少女的梦1681 天前
基于Spring Boot的游戏交易管理系统设计与实现
java·spring boot·mysql·系统设计·交易管理
Q渡劫1 天前
Redis 从安装到集成 Spring Boot 完整总结
spring boot
ruleslol1 天前
SpringBoot26-@Configuration + @Component
spring boot
霸道流氓气质1 天前
SpringBoot中使用JasperReports 报表引擎 — 介绍、原理与使用实践
java·spring boot·后端
风景的人生1 天前
流式输出与springboot中的响应式编程
java·spring boot·ai编程