The Spring MVC documentation just isn't quite there. It is pretty basic, and doesn't really help with some common medium difficulty scenarios. The one I am documenting today is how to take a typical model (with lists of dependent objects), show it in a form, and get the graph back upon submission...
Rather than go through the entire thought process from beginning to end, I am going to show the end state and then explain the major glue points that make everything work. The assumption is that you have an ok understanding of Spring MVC.
The model
Here's a simple model for the illustration. There is an object named Grid which has a list of Block objects..
public class Grid {
private List blocks =
LazyList.decorate(
new ArrayList(),
FactoryUtils.instantiateFactory(Block.class));
public List getBlocks() {
return blocks;
}
public void setBlocks(List list) {
blocks = list;
}
}
the LazyList class is the key here. This is in from the commons-collections package. I'll talk about why this is key later.
public class Block {
private String id, description;
public String getDescription() {
return description;
}
public String getId() {
return id;
}
public void setDescription(String string) {
description = string;
}
public void setId(String string) {
id = string;
}
}
分享到:
相关推荐
This is a tutorial on Spring MVC, a module in the Spring Framework for rapidly developing web applications. The MVC in Spring MVC stands for Model-View-Controller, a design pattern widely used in ...
3.0.5.RELEASE.jar,org.springframework.asm-3.0.5.RELEASE.jar,org.springframework.aspects-3.0.5.RELEASE.jar,org.springframework.beans-3.0.5.RELEASE.jar,org.springframework.binding-2.3.0.RELEASE.jar...
工程文件 博文链接:https://starscream.iteye.com/blog/1072179
Chapter 11 – Validation and data binding in Spring Web MVC Chapter 12 –Developing RESTful web services using Spring Web MVC Chapter 13 – More Spring Web MVC – internationalization, file upload and...
CVE-2022-22963 复现Demo,A Spring MVC or Spring WebFlux application running on JDK 9+ may be vulnerable to remote code execution (RCE) via data binding. The specific exploit requires the application ...
Spring MVC and Spring WebFlux web frameworks Integration: remoting, JMS, JCA, JMX, email, tasks, scheduling, cache. Languages: Kotlin, Groovy, dynamic languages. Minimum requirements JDK 8+ for Spring...
Spring MVC(Model-View-Controller)是一个基于Java的MVC(模型-视图-控制器)框架,用于构建Web应用程序。它是Spring Framework的一部分,提供了一种简单、灵活且可扩展的方式来开发Web应用程序。 下面是Spring ...
The string “area” in Route values now has special meaning in ASP.NET MVC, in the same way that “controller” and “action” do. One implication is that if ...
The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC application development in mind and provides a full suite of tools to improve development times and ...
Auto-configured Spring REST Docs Tests with Mock MVC Auto-configured Spring REST Docs Tests with REST Assured 43.3.20. User Configuration and Slicing 43.3.21. Using Spock to Test Spring Boot ...
The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC application development in mind and provides a full suite of tools to improve development times and ...
Explains the role of Controllers in the MVC framework and what role models play in binding and data access strategies Demonstrates how to display and process forms Covers the new features added in ...
Testing and testability in ASP.NET MVC Chapter 10. An executive guide to Web API Part III: Mobile clients Chapter 11. Effective JavaScript Chapter 12. Making websites mobile-friendly Chapter 13. ...
Binding) 类型装换(Type Conversion) Spring 表达式(Spring Express Language) 面向切面编程(AOP) 数据存储(Data Access) JDBC 事务抽象(Transactions) DAO 支持(DAO Support) O/R映射(O/R Mapping) XML 编列(XML ...
本文以实例形式讲述了C#应用BindingSource实现数据同步的方法,对C#数据库程序开发来说具有一定的参考借鉴价值。具体实现方法如下: 下面的代码示例演示如何使用 BindingSource 组件,将三个控件(两个文本框控件和...
Mastering Spring Cloud Packt Upsell Why subscribe? PacktPub.com Contributors About the author About the reviewer Packt is searching for authors like you Preface Who this book is for What this book ...
The increase in the affinity data available in DT knowledge-bases allows the use of advanced learning techniques such as deep learning architectures in the prediction of binding affinities. In this ...
The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC application development in mind and provides a full suite of tools to improve development times and ...