Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is <spring:bind> for? When to use it, and when not to use it?

Tags:

java

forms

spring

I am having problems with submitting form data in spring. <spring:bind> seems to be a part of the solution. See my full problem here.

The documentation of BindTag found here is not clear to me. Why is <spring:bind> needed in some cases to submit data, while it is not needed in most cases?

What are the typical cases where the <spring:bind> must be used in order for a form to function properly?

like image 313
Wellingr Avatar asked Jul 27 '11 21:07

Wellingr


People also ask

What does spring bind do?

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

What causes coilovers to bind?

In the case that the coilovers are fully threaded and offer independent ride height and spring pre-load, we recommend making sure that there isn't any more than 5mm of preload set onto the spring. Too much pre-load can cause tension on the bearing and can cause spring bind.

What is data binder in spring?

Data binding is useful for allowing user input to be dynamically bound to the domain model of an application (or whatever objects you use to process user input). Spring provides the so-called DataBinder to do exactly that.


1 Answers

You will find the tag <spring:bind> useful when you want to parse multiple objects from an input form. Here's a modified example from the Spring's doc (http://docs.spring.io/spring/docs/1.2.6/taglib/tag/BindTag.html):

<form method="post">
        ## now bind on the name of the company
        <spring:bind path="company.name">
        ## render a form field, containing the value and the expression
        Name: <input 
            type="text" 
            value="<c:out value="${status.value}"/>"
            name="<c:out value="${status.expression}"/>">
        </spring:bind>

<spring:bind path="address.street">
    Name: <input 
        type="text"
        value="<c:out value="${status.value}"/>"
        name="<c:out value="${status.expression}"/>">
</spring:bind>
<input type="submit">
</form> 
like image 105
Rocío García Luque Avatar answered Oct 10 '22 02:10

Rocío García Luque