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

相关推荐
Y***98518 分钟前
【学术会议论文投稿】Spring Boot实战:零基础打造你的Web应用新纪元
前端·spring boot·后端
4***17271 小时前
使用 java -jar 命令启动 Spring Boot 应用时,指定特定的配置文件的几种实现方式
java·spring boot·jar
8***29311 小时前
能懂!基于Springboot的用户增删查改(三层设计模式)
spring boot·后端·设计模式
源码技术栈1 小时前
什么是云门诊系统、云诊所系统?
java·vue.js·spring boot·源码·门诊·云门诊
Coder-coco2 小时前
游戏助手|游戏攻略|基于SprinBoot+vue的游戏攻略系统小程序(源码+数据库+文档)
java·vue.js·spring boot·游戏·小程序·论文·游戏助手
Qiuner2 小时前
Spring Boot 机制二:配置属性绑定 Binder 源码解析(ConfigurationProperties 全链路)
java·spring boot·后端·spring·binder
K***43065 小时前
IDEA+Docker一键部署项目SpringBoot项目
spring boot·docker·intellij-idea
t***p93511 小时前
idea创建SpringBoot自动创建Lombok无效果(解决)
spring boot·后端·intellij-idea
d***817211 小时前
解决SpringBoot项目启动错误:找不到或无法加载主类
java·spring boot·后端
自不量力的A同学14 小时前
Spring Boot 4.0.0 正式发布
java·spring boot·后端