Я пытаюсь создать приложение на странице входа и регистрации в рамках Spring.
В моей регистрационной форме идея 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>