1
<spring:bind path="aDepartment">
                <div class="form-group ${status.error ? 'has-error' : ''}">
                    <label class="col-lg-4 control-label">Department  *</label>
                    <div class="col-lg-8">
                    <form:input class="form-control" path="aDepartment" required="true"
                        placeholder="Department" />
                    <form:errors path="aDepartment" class="control-label" />
                    </div>
                </div>
</spring:bind> 

PATH is the path of the current page. When I violate validation rules (on purpose) , errors are not bound to the model and the jsp doesn't display the errors. Should I bind the errors manually to the model ? If so how can I do it ?

@RequestMapping(value = "/admin/adepartement/add", method = RequestMethod.POST)
    public String add(
            @ModelAttribute(value = "addadepartment") @Valid ADepartment pADepartment,
            final BindingResult pBindingResult, final ModelMap pModel) {
        if (!pBindingResult.hasErrors()) {
            ///
            }
        }else{
            return PATH;
        }
    } 

1 Answer 1

1

It should work just fine ! Make sure that "aDepartment" in the path refers to an attribute called "aDepartment" in your "ADepartment" Class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.