I have a problem with giving the
tag a default value.
When I created a .jsp file as follow,
The Spring form tags are for data binding (e.g. your model attributes are bind to the form via path
attribute of the form). If you need to specify defaults, then set the Content
attribute of the ModelYouArePassingToView
to the desired default value in the controller before it gets to the view.
If your using Spring MVC and @RequestMapping
, a really good place for this in your controller would be your @ModelAttribute method. For example:
@ModelAttribute("modelYouArePassingToView")
public ModelYouArePassingToView createDefault() {
//construct it with default values for "Content"
//attribute, and it will show up in textarea after the bindind
ModelYouArePassingToView myapv = new ModelYouArePassingToView();
myapv.setContent(..); //default value
return myapv;
}
In your form, make sure to include the modelAttribute
tag attribute:
<form:form modelAttribute="modelYouArePassingToView" ...>
<form:textarea path="content" ..>