estoy intentando acceder a la ruta /new-user del Controlador POST pero me esta dando un error sobre que GET no es soportado. No lo entiendo porque tengo declarada anotación de Spring @PostMapping y en el HTML tengo puesto como method=POST. Si alguien me pudiera echar una mano, para poder visualizar el horario o que me diera mas información de porque es el error. Gracias!
registration.html
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>User registration</title>
</head>
<body>
<form th:action="@{/new-user}" th:object="${user}" method="post">
<label>Usuario</label>
<input type="text" th:field="*{username}">
<label>Password</label>
<input type="text" th:field="*{password}">
<label>E-mail</label>
<input type="text" th:field="*{email}">
<button type="submit">Registrar</button>
</form>
<p><strong th:text="${reponse}"></strong></p>
</body>
</html>
UserController
package com.example.myshop.contoller;
import com.example.myshop.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
public class UserController {
@GetMapping(value = "/registration")
public String registration(Model model) {
User user = User.builder().build();
model.addAttribute("user", user);
return "/users/registration";
}
@PostMapping(value = "/new-user")
public String newUser(@ModelAttribute User user,
Model model) {
System.out.println("Inserto al usuario por BBDD" + user.getUsername());
model.addAttribute("reponse", "Usuario registrado");
return "/users/registration";
}
}
Error