Skip to content

jbek7/SpringSelectBoxSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

SpringSelectBoxSample

<form:form method="post" action="addLesson" modelAttribute="lesson"> <form:select path="course"> <form:options items="${courses}"/> </form:select> <input type="submit" name="addLesson" value="Add lesson"> </form:form>

By default, once this form is submitted - it only posts selected item as a string not full-fledged Course object.

In this sample demo, a full-fledged object can be converted by using Formatter<T>

To make it work, we need to implement Formatters to convert our course and data centers back and forth to IDs. Regarding Formatters, I’ll let you read about them in the Spring Reference Documentation: 7.6 Spring Field Formatting

This repository is created from my answer in StackOverflow -

Spring-MVC: Get full-fledged object instead of string when using 'select-options'

About

Dynamic conversion of string to a complex object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages