I got this index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Store</title>
</head>
<body>
<form action="#" th:action="@{/redirectToAddProd}" method="post">
<input type="submit" value="Submit" />
</form>
</body>
</html>
And I got this StoreController.java
@Controller
@RequestMapping("/")
public class StoreController {
@GetMapping("/")
public String index() {
return "index";
}
@GetMapping("/addProduct")
public String addProduct() {
return "addProduct";
}
@PostMapping("/redirectToAddProd")
public String redirectToAddProd() {
return "redirect:/addProduct";
}
}
My problem is, when I press the submit button nothing happens (really nothing) not a get request not even a 404. Do you have a solution? Thank you
EDIT: My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>MyStore</display-name>
<servlet>
<servlet-name>store</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/store-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>store</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
EDIT: Now I'm getting a new error. Now the button does something but is giving me the error:
sept. 20, 2017 10:08:30 AM org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupported
AVERTISSEMENT: Request method 'POST' not supported