Mapowanie do DTO masz np. tutaj: https://github.com/Pharisaeus/SpringScaffoldApplication/blob/master/src/main/java/scaffold/controllers/main/MainController.java plus https://github.com/Pharisaeus/SpringScaffoldApplication/blob/master/src/main/webapp/WEB-INF/pages/main.ftl wiele do tego nie potrzeba, @ModelAttribute
w kontrolerze i bindowanie po stronie widoku.
Próbowałem zrobić analogicznie(kontroller jest mapowany na /books):
@RequestMapping(value = "/book_list.html", method = RequestMethod.GET)
public ModelAndView getBooksListView(){
ModelAndView mav = new ModelAndView("book_list");
Iterable<Book> allData = bookRepository.findAll();
mav.addObject("books", allData);
return mav;
}
jednak po wpisaniu adresu http://localhost:8080/books/book_list.html dostaje bad request 400, z komunikatem:
Failed to convert value of type [java.lang.String] to required type [long]; nested exception is java.lang.NumberFormatException: For input string: "book_list"
Rekordy w bazie są, tak wygląda encja Book:
@Entity
@Table(name = "books")
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String author;
private String tittle;
private String ISBN;
private String language;
Przeszukałem naście tematów z takim błędem i dalej nie wiem co jest źle. Pliku z widokiem .jsp nie wrzucam, bo nie zależnie od tego co w nim jest, jest błąd. Prosze ratuj :)