Help me, please. I can’t fix this error:
'debug' enabled in Spring boot There was an unexpected error <Request method 'POST' not supported>
Thanks for your help
This my Controller
package com.example.Login1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class Login_controller {
@Autowired
Login_Service service;
@RequestMapping("/")
public String fromlogin() {
return "login";
}
@RequestMapping("/new")
public String new_User(Model model) {
User user = new User();
model.addAttribute("user", user);
return "create";
}
@RequestMapping(value = "/save" , method = RequestMethod.POST)
public String save_User(@ModelAttribute("user") User user) {
service.save(user);
return "redirect:/";
}
}
And this my HTML
<div class="container">
<form action="#" th:action="@{/save}" th:object="${user}" method="post">
<label >FullName</label>
<input type="text" id="name" name="name" placeholder="Fullname..." th:field="*{name}"/>
<label >Password</label>
<input type="text" id="password" name="Password" placeholder="Password..." th:field="*{password}"/>
<label >Email</label>
<input type="text" id="email" name="email" placeholder="email..." th:field="*{email}"/>
<label >PhoneNumber</label>
<input type="text" id="phone" name="phone" placeholder="PhoneNumber..." th:field="*{phone)}"/>
<label >Address</label>
<input type="text" id="address" name="address" placeholder="Address..." th:field="*{address}"/>
<button type="submit" value="Submit">Submit</button>
</form>
</div>
</body>
</html>
This my error