Question

I am having a problem assigning a default value to my Spring Form input field. Here's my code

<form:form method="post" modelAttribute="employeeDirectoryInfo">
      <form:input type="text" value=${employeeInfo.employee_id}>
</form>

The problem is it will say that value attribute is not valid for tag <form:input>.

Was it helpful?

Solution

Are you just trying to insert that value into the input box, or do you want to bind that property to the box (so that a new value typed by the user gets stored in that property)?

If the former, then just use a regular HTML <input type="text"> and set the value as you are doing.

If the latter, don't use "value", use "path", and leave off the ${}.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top