So I got this simple code I'd like to test but somehow it doesn't return the dataBaseEntity.html
.
@Controller
public class DataBaseMicroserviceRestConnectorProvider {
@Autowired
private DataBaseSpringDataConnectorRequester dataBaseSpringDataConnectorRequester;
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String addNewDataBaseEntityForm(Model model) {
model.addAttribute("dataBaseEntity", new DataBaseEntity());
return "dataBaseEntity";
}
The html file
is allocated in src/main/resources/templates/dataBaseEntity.html
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Handling Form Submission</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Form</h1>
<form action="#" th:action="@{/dataBaseEntity}" th:object="${dataBaseEntity}" method="post">
<p>Id: <input type="text" th:field="*{id}" /></p>
<p>Name: <input type="text" th:field="*{name}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
</body>
</html>
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
And I got a second question: is there a way to do this with @RestController
instead of @Controller
?