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
Jose Patria
1,600 PointsSpring is not recognizing my variables expressions
The ide does not recognize the expression variables ${gif.name} and send me a error but the compilations works perfect. What did i do wrong?
<img th:src="@{'/gifs/' + ${gif.name} + '.gif'}" alt="gif" />
@RequestMapping(value = "/gif")
public String gifDetails(ModelMap modelMap){
Gif gif = new Gif("compiler-bot", LocalDate.of(2017,06,06),"Jose Tomas", true);
modelMap.put("gif",gif);
return "gif-details";
}
}
4 Answers
Jose Patria
1,600 PointsWhen i compile the code works fine but the ide keep showing me this. "Validates unresolved references and invalid expressions."
In my Gif.class i have
package com.teamtreehouse.giflib.model;
import java.time.LocalDate;
public class Gif { private String name; private LocalDate dateUploaded; private String username; private boolean favorite;
public Gif(String name, LocalDate dateUploaded, String username, boolean favorite) {
this.name = name;
this.dateUploaded = dateUploaded;
this.username = username;
this.favorite = favorite;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public LocalDate getDateUploaded() {
return dateUploaded;
}
public void setDateUploaded(LocalDate dateUploaded) {
this.dateUploaded = dateUploaded;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public boolean isFavorite() {
return favorite;
}
public void setFavorite(boolean favorite) {
this.favorite = favorite;
}
}
Anders Björkland
7,481 PointsMaybe you have not got a method getName() in your Gif class?
Jose Patria
1,600 PointsWow really looks like is a bug. My template looks broke so is pretty sad. Thx mate!
Anders Björkland
7,481 PointsAh, that's a bummer. Glad to help!
Marek Dybuść
4,930 Points<!--/*@thymesVar id="gif" type="com.treehouse.smykk.giflib.model.Gif"*/-->
<img th:src="@{'/gifs/' + ${gif.getName()} +'.gif'}" alt="gif" />
...worked for me after changing 'gif.name' to 'gif.getName()', and declaring external variable in comment annotation as suggested by IntelliJ. That behavior would suggest that the 'name' field in POJO should be public in order for 'gif.name' to be recognized.
Anders Björkland
7,481 PointsAnders Björkland
7,481 PointsIs it anything like what is described over at IntelliJ's bug report site: https://youtrack.jetbrains.com/issue/IDEA-132738
...then it might be a bug of the IDE, and their suggested workaround is this: