The <form:options>
tag supports what you want right out of the box, using the items
attribute. You can do something like this:
LinkedHashMap<Integer, String> states = new LinkedHashMap<Integer, String>(); states.put(1, "Alabama"); states.put(2, "Alaska"); states.put(3, "Arizona"); states.put(4, "Arkansas"); states.put(5, "California");
And so on. Then in your form:
<form:select path="state"> <form:options items="${states}" /> </form:select>
That will be rendered to something like:
<select name="state"> <option value="1">Alabama</option> <option value="2">Alaska</option> <option value="3">Arizona</option> <option value="4">Arkansas</option> <option value="5">California</option> </select>
Related Posts:
- This application has no explicit mapping for /error
- ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
- org.springframework.web.servlet.PageNotFound noHandlerFound No mapping found for HTTP request with URI
- java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
- Difference between Spring MVC and Spring Boot
- No Spring WebApplicationInitializer types detected on classpath
- No mapping found for HTTP request with URI…. in DispatcherServlet with name [duplicate]
- Spring Hibernate – Could not obtain transaction-synchronized Session for current thread
- Spring 3 MVC resources and tag mvc:resources /
- What is a spring service annotation? [duplicate]
- Spring @PropertySources value not overriding
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- BeanFactory vs ApplicationContext
- Spring boot – Request method ‘POST’ not supported. Tried everything
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Difference between spring @Controller and @RestController annotation
- @Autowired – No qualifying bean of type found for dependency
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?
- Failed to load ApplicationContext from Unit Test: FileNotFound
- Failed to load ApplicationContext from Unit Test: FileNotFound
- UnsatisfiedDependencyException: Error creating bean with name
- UnsatisfiedDependencyException: Error creating bean with name
- Why SpringMVC Request method ‘GET’ not supported?
- Neither BindingResult nor plain target object for bean name available as request attribute
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template
- SFTP upload file Permission denied
- What does java:comp/env/ do?
- RestClientException: Could not extract response. no suitable HttpMessageConverter found
- Facing io.netty.handler.timeout.ReadTimeoutException: null while consuming server sent events
- Spring boot: Unable to start embedded Tomcat servlet container
- model.addAttribute() parameters
- navigate back with PHP form submission
- How to use Collections.sort() in Java?
- What is & used for
- How do I POST JSON data with cURL?
- How do I POST JSON data with cURL?
- An error occurred while attempting to decode the Jwt: Signed JWT rejected: Another algorithm expected, or no matching key(s) found
- Spring Boot – Unable to resolve Whitelabel Error Page
- How to fix ‘Notice: Undefined index:’ in PHP form action
- Reactjs – Form input validation
- Form submission: PHP S_SESSION statements within a foreach loop
- Understanding Spring @Autowired usage
- com.atomikos.icatch.SysException: Error in init: Log already in use? tmlog in ./
- How to define form action in JSF?
- Angular: mat-form-field must contain a MatFormFieldControl
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- “NoClassDefFoundError: Could not initialize class” error
- form control error:ERROR Error: No value accessor for form control with unspecified name attribute
- django display message after POST form submit
- Java Project: Failed to load ApplicationContext
- No value accessor for form control
- No String-argument constructor/factory method to deserialize from String value (”)
- Send POST data using XMLHttpRequest
- Setting onSubmit in React.js
- “NoClassDefFoundError: Could not initialize class” error
- “NoClassDefFoundError: Could not initialize class” error
- jQuery AJAX submit form
- No more data to read from socket error
- Why use $_SERVER[‘PHP_SELF’] instead of “”
- What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?
- Free or affordable OCR and ICR (handwriting recognition) SDK?
- Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL
- Multiple radio button groups in one form
- laravel updateOrCreate method
- Why use $_SERVER[‘PHP_SELF’] instead of “”
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- TypeScript-‘s Angular Framework Error – “There is no directive with exportAs set to ngForm”
- How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?
- How to reset a form using jQuery with .reset() method
- com.sun.jdi.InvocationException occurred invoking method
- Why php tag is not working in html file?
- Only using @JsonIgnore during serialization, but not deserialization
- Spring Maven clean error – The requested profile “pom.xml” could not be activated because it does not exist
- How do I POST JSON data with cURL?
- Get checkbox value in jQuery
- How to read if a checkbox is checked in PHP?
- Spring boot error:java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
- intellij incorrectly saying no beans of type found for autowired repository
- Could not resolve placeholder in string value
- Function not defined javascript
- How to submit a form with JavaScript by clicking a link?
- Is spring default scope singleton or not?
- JavaScript post request like a form submit
- Multiple Forms or Multiple Submits in a Page?
- How to reset a form using jQuery with .reset() method
- Cleanest way to reset forms
- “AutoComplete=Off” not working on Google Chrome Browser
- MultipartException: Current request is not a multipart request
- Submit form on pressing Enter with AngularJS
- How to create a HTML Cancel button that redirects to a URL
- How to get rid of blue outer border when clicking on a form input field?
- What does ngf-select do and why is it needed for form validation?
- No found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
- Square brackets in CSS
- What’s the difference between “Request Payload” vs “Form Data” as seen in Chrome dev tools Network tab
- How to upload a file and JSON data in Postman?
- Input Type URL – Says “Please enter a URL” if HTTP is not included