Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Spring Basics Modeling, Storing, and Presenting Data Using @PathVariable to Create a Dynamic Detail Page

Kevin Michie
Kevin Michie
6,554 Points

gif.favorite creates an error

adding this statement:

<a href="#" th:class="(${gif.favorite} ? 'un' : '') + 'mark favorite'"></a>

produces this error:

There was an unexpected error (type=Internal Server Error, status=500). Exception evaluating SpringEL expression: "gif.favorite" (gif-details:50)

2 Answers

I don't know why it works. I think you missed @ sign, because I had the same problem, I just compared with img tag and found the difference.


<a href="#" th:class="@{${gif.favorite} ? 'un' : ''} + 'mark favorite'"></a>
Alexander Nikiforov
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

If it is still relevant...

Check your getter name for favorite property. It should be public boolean isFavorite(). This way error will be removed. If you have this getter right though, please paste your Gif class and errors in log of Intellijidea (there should be more information, especially Thymeleaf error).