dochsner
dochsner

Reputation: 249

Thymeleaf Pagination Url Failed to Convert String to Long

So I'm trying to paginate results where I have a page with a path variable, and the Thymeleaf th:href keeps telling me Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'

So I added an object called "StudySet" to the model in my controller method, like this

modelAndView.addObject("studySet", studySetById);

And then I try to use it in a th:href in my HTML like this

th:href= "@{${studySet.id}/?page=} + ${page}"

But my URL just shows up like this

http://localhost:8080/studySet/$%7BstudySet.id%7D/?page=2

When I want it to look like this

http://localhost:8080/studySet/8/?page=2

8 is the id of the "studySet" object.

So if anyone has any idea on what I'm doing wrong and could let me know, that would be awesome, thanks.

Upvotes: 0

Views: 1267

Answers (1)

Enigo
Enigo

Reputation: 3885

ok, I reproduced your problem and here is a solution:

th:href= "@{{studySetid}/?page={page}(studySetid=${studySet.id},page=${page})}"

here is a reference for further reading

Upvotes: 2

Related Questions