How is the Spring MVC spring:bind tag working and what are the meanings of status.expression and status.value?

StackOverflow https://stackoverflow.com/questions/614729

  •  03-07-2019
  •  | 
  •  

Question

Let's discuss on the following example:

<spring:bind path="user.userName">
    <input type="text" name="${status.expression}" value="${status.value}"/>
    <span class="fieldError">${status.errorMessage}</span>
</spring:bind>

When this view snippet gets rendered, what do ${status.expression} and ${status.value} get evaluated to? Where do these values come from?

Was it helpful?

Solution

See this link for an explanation of what the status variables mean.

  • status.expression: the expression that was used to retrieve the bean or property
  • status.value: the actual value of the bean or property (transformed using registered PropertyEditors)
  • status.errorMessages: an array of error messages, resulting from validation

The status object is evaluated when the binding is done.

Also have in mind that Spring 2.0 introduced new form tags, which are probable better suited for your needs.

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