Проверка тимелеафа

Я изучаю раздел проверки тимелеафа, и у меня есть ошибка, например

Исключение при оценке выражения SpringEL: "# fields.hasErrors ('jobtitle')" (authentication / contactus: 19)

В моей форме есть следующее поле

        <div class="form50">
            <label for="contact.emailAddress"><span th:text="#{contact.email}">Email</span></label>
             <span class="error" th:if="${#fields.hasErrors('email')}" th:errors="email"></span>
            <input type="email" th:field="*{email}" class="field50" th:classappend="${#fields.hasErrors('email')}? 'fieldError'" />
        </div>

        <div class="form50">
            <label for="customer.firstName"><span th:text="#{contact.jobtitle}">Job Title</span></label>
            <span class="error" th:if="${#fields.hasErrors('jobtitle')}" th:errors="*{jobtitle}"></span>
            <input type="text" th:field="*{jobtitle}" class="field50" th:classappend="${#fields.hasErrors('name')}? 'fieldError'" />
        </div>

        <div class="login_register">
            <input class="register_button big red" type="submit" th:value="#{contact.contact}"/>
        </div>

    </blc:form>

когда я удаляю jobtitle div, он работает нормально

myvalidator класс выглядит следующим образом

public void validate(Object obj, Errors errors, boolean useEmailForUsername) {
        ContactCustomerForm form = (ContactCustomerForm) obj;
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "name.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "emial.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "jobtitle", "jobtitle.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "country", "country.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phone", "phone.required");
}

В чем проблема, которую я не могу определить !!!!!! Пожалуйста, помогите


person user7789076    schedule 06.09.2013    source источник
comment
Более интересное сообщение находится глубже в трассировке стека. Вы можете опубликовать полную версию?   -  person Martin Frey    schedule 06.09.2013
comment
Не могли бы вы сначала проверить свой код, кажется, что ваши элементы формы немного перепутаны. И опубликовать весь элемент формы ...   -  person Blejzer    schedule 29.06.2015


Ответы (1)


Проблема в следующей строке

<span class="error" th:if="${#fields.hasErrors('email')}" th:errors="email"></span>

должно быть

th:errors="*{email}"

так же, как эта строка в вашем коде ниже

<span class="error" th:if="${#fields.hasErrors('jobtitle')}" th:errors="*{jobtitle}"></span>
person Lukas Grygar    schedule 08.11.2015