X
X
xxxxc2018-03-30 10:19:30
Spring
xxxxc, 2018-03-30 10:19:30

Validation errors stack, how to fix?

Tell me why is this happening? Why are validation errors one on one?
5abde2a65188c013315156.png
In the developer console, it shows only 2 spans, on the screen you can clearly see that there are more.
Through ctrl+F5 new ones appear...
I use SpringMVC. The controller returns a ModelAndView object.
It uses the following code:

if (bindingResult.hasErrors()) {
      modelAndView.setViewName("registration");
      modelAndView.addObject("user", user);
      return modelAndView;
    }

In html:
<span class="alert alert-danger" th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></span>

Also, can anyone tell me, if a validation error occurs, all fields in the form become empty. How to fix? I thought that modelAndView.addObject("user", user); should have solved it, but no.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xxxxc, 2018-03-30
@xxxxc

Decided display:inline-block
Well, as I use thymeleaf, then to fill in the fields, after the error:
th:value="${user.userName}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question