I have an endpoint:
@GetMapping("book/param")
public String bookByParam(
@RequestParam(required = false,name = "name") String name,
@RequestParam(required = false,name = "author") String author,
@RequestParam(required = false,name = "genre") String genre,
@RequestParam(required = false,name = "genre") int price, Model m
){
List<Books> books = bookService.showSpecificBooks(name, author, genre,price);
m.addAttribute("books", books);
return "book";
}
For the params I wrote querys so they can be null that means if i dont input anything I will get all books.
Now I have my books.html template with following implemenation:
<form th:action="@{book/param}" th:object="${books}" method="get">
<label for="name">name:</label><br>
<input type="text" id=name th:field="name" placeholder="name">
<label for="author">author:</label><br>
<input type="text" id=author th:name="author" placeholder="author">
<label for="genre">genre:</label><br>
<input type="text" id=genre th:name="genre" placeholder="genre">
<label for="price">price:</label><br>
<input type="number" id=price th:name="price" placeholder="price">
</form>
I would expect that I would get a List of books within the range of the submitted values and when I have no input I would get (because of my Query) all books but all I get is a TemplateInputException: An error happened during template parsing. I also tried to wrap the object names like this:
<input type="text" id=name th:field="*{name}" placeholder="name">
or like this :
<input type="text" id=name th:field="${name}" placeholder="name">
but unfortunately it did not work. Can anyone see what I am doing from. Thanks in advance