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

相关推荐
中式代码美式咖啡5 小时前
记录开发一个英语听力训练网站
java·spring boot·bootstrap·音视频·语音识别
Flying_Fish_roe5 小时前
Spring Boot-Bean注入问题
spring boot·后端·log4j
.生产的驴6 小时前
SpringBoot 消息队列RabbitMQ 消息可靠性 数据持久化 与 LazyQueue
java·spring boot·后端·eclipse·rabbitmq·maven·java-rabbitmq
毕设木哥7 小时前
25届计算机毕业设计选题推荐-图书馆智能选座系统
java·spring boot·微信小程序·小程序·毕业设计·课程设计
程序员大金9 小时前
基于SpringBoot+Vue+MySQL的网上租赁系统
java·前端·javascript·vue.js·spring boot·后端·mysql
云来喜10 小时前
关于Spring Cloud Gateway中 Filters的理解
java·spring boot·gateway
灯火不休ᝰ10 小时前
6--SpringBootWeb案例(详解)
spring boot·后端·mybatis
Flying_Fish_roe11 小时前
Spring Boot- 配置中心问题
spring boot·后端·elasticsearch
杨荧12 小时前
【JAVA开源】基于Vue和SpringBoot的在线旅游网站
java·vue.js·spring boot·spring cloud·开源
计算机学姐12 小时前
基于SpringBoot+Vue的个性化旅游推荐系统
java·vue.js·spring boot·后端·intellij-idea·mybatis·旅游