ajax表单提交
 
$.ajax({
                cache: true,
                type: "POST",
                url:ajaxCallUrl,
                data:$('#yourformid').serialize(),// 你的formid
                async: false,
                error: function(request) {
                    alert("Connection error");
                },
                success: function(data) {
                    $("#commonLayout_appcreshi").parent().html(data);
                }
            });
表单中用 字段对应的是  name 不是id
普通提交表单:直接在form表单中加个id,<form id="formId"></form>,弄个buttom按钮进行提交,加个onclick="js函数",然后在js函数中$("#formId").submit(); 就OK.
 
=========================

继前面一篇 springMVC 页面中多个对象的数据绑定 ,本文主要介绍如果实现复杂类型对象的数据绑定,比如前文中的父级对象CourseInfo 中增加:String[] times , List<Student> studentList 这两个复杂类型属性,页面中数据如何才能准确绑定到对象上呢?

参考来源:http://www.360doc.com/content/16/1022/15/37520906_600479377.shtml

【类】

public class CourseInfo {
private Course course;
private Teacher teacher;
private String[] times;
private List<Student> studentList;
}

public class Student extends IdEntity {
private String name;
private String email;
private String className;
}

【页面】

 <form:form id="input-form" modelAttribute="courseInfo"
action="${ctx}/demo/course.do?method=save" method="post">
<input type="hidden" name="id" value="${course.id}" />
<fieldset class="prepend-top">
<legend>课程信息</legend>
<div id="messageBox" class="error-msg" style="display: none">输入有误,请先更正。</div>
<div>
<label for="course.name" class="field">课程名称:</label>
<input
type="text" id="course.name" name="course.name" size="20"
value="${courseInfo.course.name}" class="required" />
</div>
<div>
<label for="course.description" class="field">课程介绍:</label>
<input
type="text" id="course.description" name="course.description"
size="20" value="${courseInfo.course.description}" class="required" />
</div> <div>
<label for="teacher.name" class="field">老师姓名:</label>
<input
type="text" id="teacher.name" name="teacher.name" size="20"
value="${courseInfo.teacher.name}" class="required" />
</div>
<div>
<label for="teacher.email" class="field">老师Email:</label>
<input
type="text" id="teacher.email" name="teacher.email" size="20"
value="${courseInfo.teacher.email}" class="required" />
</div>
<div>
<label for="times" class="field">上课时间:</label>
<input type="text" id="times[0]" name="times" size="20" value="周一" class="required" />
<input type="text" id="times[1]" name="times" size="20" value="周三" class="required" />
<input type="text" id="times[2]" name="times" size="20" value="周五" class="required" />
</div> <div>
<label for="studentList[0].name" class="field">学生1姓名:</label>
<input type="text" id="studentList[0].name" name="studentList[0].name" size="20" value="学生1姓名" class="required" />
</div>
<div>
<label for="studentList[0].email" class="field">学生1Email:</label>
<input type="text" id="studentList[0].email" name="studentList[0].email" size="20" value="学生1Email" class="required" />
</div>
<div>
<label for="studentList[1].name" class="field">学生2姓名:</label>
<input type="text" id="studentList[1].name" name="studentList[1].name" size="20" value="学生2姓名" class="required" />
</div>
<div>
<label for="studentList[1].email" class="field">学生2Email:</label>
<input type="text" id="studentList[0].email" name="studentList[1].email" size="20" value="学生2Email" class="required" />
</div>
</fieldset>

页面提交 string数组和list对象集合举例的更多相关文章

  1. 前端页面传来数组,后台用对象集合list接收数据的写法

    //保存页面显示应用$("#save").click(function(){ var data = [{"applicationtypeid":"65 ...

  2. springMVC接受对象集合,name数组

    这两天开发遇到一个很常见的问题,即使自己一直没遇见过,不过之前看过是实现接受对象集合的代码,只不过没注意罢了 推荐一篇文章 直接贴代码吧 public class Person { private S ...

  3. Java技巧——将前端的对象数组通过Json字符串传到后端并转换为对象集合

    Java技巧——将前端的对象数组通过Json字符串传到后端并转换为对象集合 摘要:本文主要记录了如何将将前端的对象数组通过Json字符串传到后端,并在后端将Json字符串转换为对象集合. 前端代码 前 ...

  4. SpringMVC,SpringBoot使用ajax传递对象集合/数组到后台

    假设有一个bean名叫TestPOJO. 1.使用ajax从前台传递一个对象数组/集合到后台. 前台ajax写法: var testPOJO=new Array(); //这里组装testPOJO数组 ...

  5. ArrayList集合、String[]数组、String字符串

    数组初始化时候必须指定长度,而ArrayList是动态数组,可以根据实际内容改变 //声明stsArr数组并初始化 String[] strArr = new String[]{ "aaa& ...

  6. UI自动化测试(三)对页面中定位到的元素对象做相应操作

    前两天分别讲述了UI自动化测试基础以及对页面元素该如何进行定位,这一篇自然就是对定位到的页面元素对象进行相应操作啦. 阅读目录 1.常用操作元素对象的方法 2.鼠标事件操作 3.键盘事件操作 4.We ...

  7. servlet自动获取前端页面提交数据

    servlet自动获取前端页面jsp提交数据 以下是本人在学习过程中,因前端页面提交参数过多,后台servlet封装实体类过于麻烦而写的一个工具类,应用于jsp/servlet数据提交后,基于MVC+ ...

  8. MVC传递数据-传递对象或对象集合

    前言 本文主要介绍从View(或者js)文件向Controller提交对象或者对象集合.比方.将表格中的一行数据作为一个对象提交.或将多行数据作为一个集合提交到Controller. 回想 从View ...

  9. JSon_零基础_008_将JSon格式的"数组"字符串转换为List集合

    将JSon格式的"数组"字符串转换为List集合. 应用此技术从一个json对象字符串格式中得到一个java对应的对象. JSONObject是一个“name.values”集合, ...

随机推荐

  1. 【转】chrome 67版本后无法拖拽离线安装CRX格式插件的解决方法

    第一种:开启开发者模式即可 (推荐) chrome  的设置 -> 更多工具 -> 扩展程序,开启开发者模式即可! 第二种方法:修改参数 首先打开下面地址:chrome://flags/# ...

  2. Docker 学习记录

    docker logs 查看日志 docker logs  容器id docker logs -f 容器id 这次命令后面添加了一个新的标识 -f. 和 tail -f 类似, docker logs ...

  3. 第一个版本库 Repository

    Git安装 Windows系统 Git 为 Windows 系统提供了简易的 .exe 安装包, 直接下载并安装就可以了(点这里->):https://git-scm.com/download/ ...

  4. nginx for windows 中虚拟主机路径设置问题

    由于Windows版本的Nginx其实是在Cygwin环境下编译的,所以Nginx使用的是Cygwin的路径格式,所以在Nginx的配置文件nginx.conf中,路径既不能使用*nix的格式,也不能 ...

  5. Java循环跳转语句之 break

    生活中,我们经常会因为某些原因中断既定的任务安排.如在参加 10000 米长跑时,才跑了 500 米就由于体力不支,需要退出比赛.在 Java 中,我们可以使用 break 语句退出指定的循环,直接执 ...

  6. lessc的安装

    win+R,cmd打开命令面板,输入cnpm install -g less,如图,然后就可以通过lessc -v查询lessc的版本,出现版本号证明安装成功

  7. Memcached CAS 命令

    Memcached CAS(Check-And-Set 或 Compare-And-Swap) 命令用于执行一个"检查并设置"的操作 它仅在当前客户端最后一次取值后,该key 对应 ...

  8. net.paoding.analysis.exception.PaodingAnalysisException: dic home should not be a file, but a directory!

    Caused by: net.paoding.analysis.exception.PaodingAnalysisException: dic home should not be a file, b ...

  9. Ubuntu下配置舒服的Python开发环境

    Ubuntu 提供了一个良好的 Python 开发环境,但如果想使我们的开发效率最大化,还需要进行很多定制化的安装和配置.下面的是我们团队开发人员推荐的一个安装和配置步骤,基于 Ubuntu 12.0 ...

  10. influxdb和boltDB简介——MVCC+B+树,Go写成,Bolt类似于LMDB,这个被认为是在现代kye/value存储中最好的,influxdb后端存储有LevelDB换成了BoltDB

    influxdb influxdb是最新的一个时间序列数据库,最新一两年才产生,但已经拥有极高的人气.influxdb 是用Go写的,0.9版本的influxdb对于之前会有很大的改变,后端存储有Le ...