Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

spring-mvc

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?

like image 873
Ogo Pogo Avatar asked Mar 05 '09 13:03

Ogo Pogo


People also ask

What is spring bind tag?

General information. The spring:bind tag provides you with support for evaluation of the status of a certain bean or bean property.

What is spring MVC model?

In Spring MVC, the model works a container that contains the data of the application. Here, a data can be in any form such as objects, strings, information from the database, etc. It is required to place the Model interface in the controller part of the application.

Is spring MVC still used?

@PanadolChong accomodate Spring MVC is still used in some legacy applications, and Spring boot does majority of the configurations under-hood so to have a better understanding of how things work internally, Spring MVC might help.


1 Answers

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.

like image 106
kgiannakakis Avatar answered Oct 09 '22 23:10

kgiannakakis