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
- Reactjs – Form input validation
- Angular: mat-form-field must contain a MatFormFieldControl
- Multiple Forms or Multiple Submits in a Page?
- Configure active profile in SpringBoot via Maven
- How to install Date Picker form control in Excel 2016
- when spring boot startup,throw out the “method names must be tokens” exception
- Validate form before submit jquery
- ngular is automatically adding ‘ng-invalid’ class on ‘required’ fields
- How to handle form submission?
- How can I make wp-pagenavi work on a custom query built upon a form submission? [closed]
- using update_user_meta in form to set and get custom meta
- Add X meta box inputs based on form at top of meta box, how to do it right?
- How to create and retrieve data from a special registration form?
- Contact form 7 Dynamic text – placeholder on GET field
- Settings API erases itself?
- Creating a WordPress form with a PHP script and default header
- How can I fix a slow redirect after form submit from frontend (no plugin)?
- Storing textbox values in Database
- How to update selective options on plugin settings page
- Front End Registration Form Code – Password Field Not Saving
- Making the wordpress login form a jQuery dropdown
- RSVP form for Facebook events from a WordPress post?
- Adding Custom Forms
- wp_create_nonce function doesn’t work inside a plugin?
- How to limit the number of forgot password reset attempts in WordPress?
- How can I create registration form for users which I can assign role and profile picture?
- Show the submitted values in the form when validation fails
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Contact Form 7 form is working on local wordpress install but fails on production server [closed]
- How to execute html code inside php?
- Uncaught ReferenceError: jQuery is not defined – although jQuery is loaded [closed]
- jQuery will not work on page from snippet or file
- How to create new template page and template-parts in wordpress theme [closed]
- Outputting something based on the presence of post variable in admin screens
- Custom form handling in WP.. the correct way?
- How to have multiple instances of the same taxonomy in a search form
- Custom form not showing in correct place on page
- Copy and Paste Password for Comments
- How to Use the Filter “sidebar_login_widget_form_args”
- Search a title word through query_posts (not the exact match)
- Contact Form 7 Plugin emails not being received by some accounts
- How to stop direct HTTP POST to a PHP script?
- Making a form for user to add new custom post with custom taxonomies and custom fields
- What should I write in the post action of this front end post form?
- Contact form – problem with displaying message about sent mail
- Creating a User-Adjustable chart in WordPress
- I want to retrieve the email or username data entered for password reset, but failed. how can I do it?
- form submission reverts to index.php template
- How can I create a Survey Form in WordPress that users can fill in and then submit the entire survey contents as a post?
- WP Ajax returning 0, can’t find action
- Back button not working after input / search submit
- I am trying to add checkbox for anonymous post on form post
- How to send custom mail when a user complete a specific form
- Programmatically create new post from a metabox button
- Simple filter to change label name of Email Adress to something else
- Custom transactional emails on user signup with wp_add_user
- WordPress, Front-end send message to authors using plugin when their post is published
- How to hide the form after successful php execution
- Acessing WP functions in form submission handler
- Using AJAX for dynamic settings pages
- Display single post inside accordion based on form submission results
- Display default WordPress login/registration form into a modal window
- Carrying information from button click into form [closed]
- Custom form values without plugin [closed]
- County Finder form/plugin?
- How do I insert a custom field in a user submitted post?