Spring Thymeleaf не может разрешить 'global'

Я пытаюсь создать приложение для входа в систему в Spring framework.

В моей регистрационной форме идея intelij говорит, что невозможно разрешить "глобальный".

Я изменил springsecurity4 на springsecurity3, но ничего не изменил.

Это мой элемент формы:

<form class = "form-signin" th:action = "@{/registration}" th:object = "${user}" method = "post">
  <input type = "text" class = "form-control" placeholder = "Full Name" th:field = "*{fullname}" required autofocus>
  <label style = "color: red" th:if = "${#fields.hasErrors('fullname')}" th:errors = "*{fullname}">Username Error</label>
  <input type = "text" class = "form-control" placeholder = "email" th:field = "*{email}" required autofocus>
  <label style = "color: red" th:if = "${#fields.hasErrors('email')}" th:errors = "*{email}">Username Error</label>
  <input type = "password" class = "form-control" placeholder = "Password ..." name = "password" required>
  <label style = "color: red" th:if = "${#fields.hasErrors('password')}" th:errors = "*{password}">Password Error</label>
  <input type = "submit" class = "btn btn-lg btn-default btn-block" value = "Sign Up" />
  <td th:if = "${#fields.hasGlobalErrors()}" th:errors = "*{global}">Global Error</td>
</form>

это мой элемент html:

<html xmlns = "http://www.w3.org/1999/xhtml" xmlns:th = "http://www.thymeleaf.org" xmlns:sec = "http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">

Это мой метод контроллера:

@RequestMapping(value = "/registration", method = RequestMethod.POST)
public ModelAndView createNewUser(@Valid User user, BindingResult bindingResult) {
    ModelAndView modelAndView = new ModelAndView();
    User userExists = userService.findUserByEmail(user.getEmail());
    if (userExists != null) {
        bindingResult
                .rejectValue("email", "error.user",
                        "There is already a user registered with the email provided");
    }
    if (bindingResult.hasErrors()) {
        modelAndView.setViewName("registration");
    } else {
        userService.saveUser(user);
        modelAndView.addObject("successMessage", "User has been registered successfully");
        modelAndView.addObject("user", new User());
        modelAndView.setViewName("registration");

    }
    return modelAndView;
}

Это мой файл pom.xml:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</artifactId>
    </dependency>
</dependencies>

Зачем понижать рейтинг Springsecurity?

holmis83 27.04.2018 21:54

@ holmis83 Я хотел попробовать все, чтобы решить эту проблему.

Mert Doe 01.05.2018 12:32
0
2
749
1

Ответы 1

Я считаю, что источник проблемы связан с тегом th:object и что решение (фактически связанное с другими связанными вопросами) уже можно найти здесь: Проверка Spring Thyme Leaf на наличие глобальных ошибок приводит к NPE

Кроме того, я заметил, что вы используете тег <td> вне элемента <table>, это не то, как его следует использовать в соответствии с: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td

Другие вопросы по теме