вывод ошибки пользователю spring thymeleaf validation

Мне нужно завалидировать тип документа( выбрать пункт) и подгрузить файл (обязательно), тогда можно сохранить.

введите сюда описание изображения

Сам метод. Где я ловлю отработанный @Valid.

    @RequestMapping(value = EDIT + STUDENT_DOCUMENT + "/add", method = RequestMethod.POST)
public String addDocument( @ModelAttribute("newDocument") @Valid DocDTO studentDocumentDTO,
                          BindingResult res,
                          Model model,
                          @RequestParam(value = "studentId") long studentId,
                          @RequestParam(value = "file", required = true) MultipartFile file,
                          @RequestParam(value = "documentTypeId", required = true) Long docTypeId) {
    if (res.hasErrors()) {

        return "redirect:" + STUDENTS + EDIT + STUDENT_DOCUMENT + studentId;
    }

thymeleaf

И здесь ошибку надо передать пользователю

         <div class="col-xs-4 form-group">
                <label for="documentType" th:text="#{StudentController.add.document.type}"></label>
                <select id="documentType" class="form-control" name="documentTypeId"
                        th:disabled="${isWiewing}">
                    <option value="0" selected="selected" th:text="#{StudentController.add.notInstalled}"></option>
                    <option th:each="docType: ${documentTypes}"
                            th:value="${docType.id}"
                            th:text="${docType.type}">
                    </option>
                </select>

            </div>
            <div class="col-xs-4 form-group">
                <label for="file" th:text="#{StudentController.add.document.add}"></label>
                <input id="file" type="file" name="file" onchange="fileOnChange()"/>
            </div>
            <div class="row">
                <div class="col-xs-4" sec:authorize="hasAnyRole('ROLE_ADMIN' ,'ROLE_TUTOR')">
                    <input type="submit" class="btn btn-primary" th:value="#{save}"/>
                </div>
            </div>

Пытаюсь вставить в шаблон к примеру:

<p th:if="${#fields.hasErrors('documentTypeId')}">Invalid </p>

бессмысленно


Ответы (0 шт):