Reputation: 1
I am using Spring MVC and Freemarker.
I have created a form and I want to put a default value into a formInput
<@spring.formInput "command.name"/>
please give any suggestions.
Upvotes: 0
Views: 1359
Reputation: 4434
You can specify a default value in your Spring MVC Controller. But you mention Freemarker. To specify a default value using Freemarker, you follow the variable name with a ! and then the default value. For example, from the documentation (http://freemarker.org/docs/dgui_quickstart_template.html):
<h1>Welcome ${user!"visitor"}!</h1>
However, with that said, the documentation does not seem to show a way to specify a default way within a form. That leaves me with the conclusion that you need to set the value in the "command object" or "backing object" being sent to the form rather than using the template itself.
Upvotes: 1