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

Could not parse as expression

With this code:

        <!--/*@thymesVar id="favorite" type="java"*/-->
        <!--/*@thymesVar id="gif" type="java"*/-->
        <a href="#" th:class="(${gif.favorite} ? 'un':'')'mark favorite'"></a>

*See please at the end

I am getting this error:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Aug 17 10:05:43 CEST 2017 There was an unexpected error (type=Internal Server Error, status=500). Could not parse as expression: "(gif.favorite ? 'un':'')'mark favorite'" (gif-details:55)

*I do not know what those comments are, Intellij is asking for them, it removes the the error (red highlight) for the 'gif' word, but not for the 'favorite' word. It seems like I missed sthg here...

1 Answer

Boban Talevski
Boban Talevski
24,793 Points

I guess you figured it out by now, but just in case: you are missing a plus sign between the ternary operator and the 'mark favourite' literal :)

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