Thymeleaf SpringEL expression
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have such problem with thymeleaf template. I am getting:
Exception evaluating SpringEL expression: "prod.itemName" (main:18)
from this expression:
<tr th:each="prod: ${product}">
<td th:text="${prod.itemName}">sdfsdf</td>
<td th:text="${prod.price}">asdasd</td>
<td>asddasdas</td>
</tr>
product is a List of passed as model attribute to thymeleaf template. I am wondering why it doesn't work properly.
I used this source:
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#iteration-basics
EDITED:
package shopbasket;
public class Item {
String itemName;
double price;
Item(String itemName, double price){
this.itemName=itemName;
this.price=price;
}
void setItemName(String itemName) {
this.itemName=itemName;
}
String getItemName() {
return itemName;
}
void setPrice(float price) {
this.price=price;
}
double getPrice() {
return price;
}
}
java spring loops thymeleaf
|
show 8 more comments
I have such problem with thymeleaf template. I am getting:
Exception evaluating SpringEL expression: "prod.itemName" (main:18)
from this expression:
<tr th:each="prod: ${product}">
<td th:text="${prod.itemName}">sdfsdf</td>
<td th:text="${prod.price}">asdasd</td>
<td>asddasdas</td>
</tr>
product is a List of passed as model attribute to thymeleaf template. I am wondering why it doesn't work properly.
I used this source:
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#iteration-basics
EDITED:
package shopbasket;
public class Item {
String itemName;
double price;
Item(String itemName, double price){
this.itemName=itemName;
this.price=price;
}
void setItemName(String itemName) {
this.itemName=itemName;
}
String getItemName() {
return itemName;
}
void setPrice(float price) {
this.price=price;
}
double getPrice() {
return price;
}
}
java spring loops thymeleaf
is it possible that prod.itemName is null?
– Clomez
Nov 16 '18 at 10:32
I think it can't be null
– graluc
Nov 16 '18 at 10:34
Are you certain that you have all the getters and setters for the class? im looking at the exact same code overhere, and its working :/
– Clomez
Nov 16 '18 at 10:36
Just a guess...prod: ${product}- Assuming that everything else is actually ok, could it be that you need a whitespace before the colon, likeprod : ${product}? Almost every snippet online has that whitespace, even the tutorial you linked does. Maybe that's the issue here
– BackSlash
Nov 16 '18 at 10:45
1
The type ofprodprobably isn't what you think it is. Output just${prod}in the loop and see what class ThymeLeaf tells you it is and proceed from there.
– Metroids
Nov 16 '18 at 15:54
|
show 8 more comments
I have such problem with thymeleaf template. I am getting:
Exception evaluating SpringEL expression: "prod.itemName" (main:18)
from this expression:
<tr th:each="prod: ${product}">
<td th:text="${prod.itemName}">sdfsdf</td>
<td th:text="${prod.price}">asdasd</td>
<td>asddasdas</td>
</tr>
product is a List of passed as model attribute to thymeleaf template. I am wondering why it doesn't work properly.
I used this source:
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#iteration-basics
EDITED:
package shopbasket;
public class Item {
String itemName;
double price;
Item(String itemName, double price){
this.itemName=itemName;
this.price=price;
}
void setItemName(String itemName) {
this.itemName=itemName;
}
String getItemName() {
return itemName;
}
void setPrice(float price) {
this.price=price;
}
double getPrice() {
return price;
}
}
java spring loops thymeleaf
I have such problem with thymeleaf template. I am getting:
Exception evaluating SpringEL expression: "prod.itemName" (main:18)
from this expression:
<tr th:each="prod: ${product}">
<td th:text="${prod.itemName}">sdfsdf</td>
<td th:text="${prod.price}">asdasd</td>
<td>asddasdas</td>
</tr>
product is a List of passed as model attribute to thymeleaf template. I am wondering why it doesn't work properly.
I used this source:
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#iteration-basics
EDITED:
package shopbasket;
public class Item {
String itemName;
double price;
Item(String itemName, double price){
this.itemName=itemName;
this.price=price;
}
void setItemName(String itemName) {
this.itemName=itemName;
}
String getItemName() {
return itemName;
}
void setPrice(float price) {
this.price=price;
}
double getPrice() {
return price;
}
}
java spring loops thymeleaf
java spring loops thymeleaf
edited Nov 16 '18 at 13:23
OhleC
1,840921
1,840921
asked Nov 16 '18 at 10:30
gralucgraluc
6110
6110
is it possible that prod.itemName is null?
– Clomez
Nov 16 '18 at 10:32
I think it can't be null
– graluc
Nov 16 '18 at 10:34
Are you certain that you have all the getters and setters for the class? im looking at the exact same code overhere, and its working :/
– Clomez
Nov 16 '18 at 10:36
Just a guess...prod: ${product}- Assuming that everything else is actually ok, could it be that you need a whitespace before the colon, likeprod : ${product}? Almost every snippet online has that whitespace, even the tutorial you linked does. Maybe that's the issue here
– BackSlash
Nov 16 '18 at 10:45
1
The type ofprodprobably isn't what you think it is. Output just${prod}in the loop and see what class ThymeLeaf tells you it is and proceed from there.
– Metroids
Nov 16 '18 at 15:54
|
show 8 more comments
is it possible that prod.itemName is null?
– Clomez
Nov 16 '18 at 10:32
I think it can't be null
– graluc
Nov 16 '18 at 10:34
Are you certain that you have all the getters and setters for the class? im looking at the exact same code overhere, and its working :/
– Clomez
Nov 16 '18 at 10:36
Just a guess...prod: ${product}- Assuming that everything else is actually ok, could it be that you need a whitespace before the colon, likeprod : ${product}? Almost every snippet online has that whitespace, even the tutorial you linked does. Maybe that's the issue here
– BackSlash
Nov 16 '18 at 10:45
1
The type ofprodprobably isn't what you think it is. Output just${prod}in the loop and see what class ThymeLeaf tells you it is and proceed from there.
– Metroids
Nov 16 '18 at 15:54
is it possible that prod.itemName is null?
– Clomez
Nov 16 '18 at 10:32
is it possible that prod.itemName is null?
– Clomez
Nov 16 '18 at 10:32
I think it can't be null
– graluc
Nov 16 '18 at 10:34
I think it can't be null
– graluc
Nov 16 '18 at 10:34
Are you certain that you have all the getters and setters for the class? im looking at the exact same code overhere, and its working :/
– Clomez
Nov 16 '18 at 10:36
Are you certain that you have all the getters and setters for the class? im looking at the exact same code overhere, and its working :/
– Clomez
Nov 16 '18 at 10:36
Just a guess...
prod: ${product} - Assuming that everything else is actually ok, could it be that you need a whitespace before the colon, like prod : ${product}? Almost every snippet online has that whitespace, even the tutorial you linked does. Maybe that's the issue here– BackSlash
Nov 16 '18 at 10:45
Just a guess...
prod: ${product} - Assuming that everything else is actually ok, could it be that you need a whitespace before the colon, like prod : ${product}? Almost every snippet online has that whitespace, even the tutorial you linked does. Maybe that's the issue here– BackSlash
Nov 16 '18 at 10:45
1
1
The type of
prod probably isn't what you think it is. Output just ${prod} in the loop and see what class ThymeLeaf tells you it is and proceed from there.– Metroids
Nov 16 '18 at 15:54
The type of
prod probably isn't what you think it is. Output just ${prod} in the loop and see what class ThymeLeaf tells you it is and proceed from there.– Metroids
Nov 16 '18 at 15:54
|
show 8 more comments
2 Answers
2
active
oldest
votes
This one:
<tr th:each="prod : ${prods}">
<td th:text="${prod}">sdfsdf</td>
<td th:text="${prod}">asdasd</td>
<td>asddasdas</td>
</tr>
gives output:
shopbasket.Item@10d9f966 shopbasket.Item@10d9f966 asddasdas
shopbasket.Item@1346081f shopbasket.Item@1346081f asddasdas
shopbasket.Item@4c8bc1d8 shopbasket.Item@4c8bc1d8 asddasdas
shopbasket.Item@7b0d2332 shopbasket.Item@7b0d2332 asddasdas
shopbasket.Item@6e38515f shopbasket.Item@6e38515f asddasdas
shopbasket.Item@4d9daa77 shopbasket.Item@4d9daa77 asddasdas
shopbasket.Item@5f0a371d shopbasket.Item@5f0a371d asddasdas
shopbasket.Item@4d0c8b7d shopbasket.Item@4d0c8b7d asddasdas
shopbasket.Item@6112892a shopbasket.Item@6112892a asddasdas
shopbasket.Item@41fc596d shopbasket.Item@41fc596d asddasdas
shopbasket.Item@4fc03c90 shopbasket.Item@4fc03c90 asddasdas
shopbasket.Item@663e1176 shopbasket.Item@663e1176 asddasdas
shopbasket.Item@13909f42 shopbasket.Item@13909f42 asddasdas
add a comment |
try this form instead : <td th:inline="text">[[${prod.price}]]</td>
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53335986%2fthymeleaf-springel-expression%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This one:
<tr th:each="prod : ${prods}">
<td th:text="${prod}">sdfsdf</td>
<td th:text="${prod}">asdasd</td>
<td>asddasdas</td>
</tr>
gives output:
shopbasket.Item@10d9f966 shopbasket.Item@10d9f966 asddasdas
shopbasket.Item@1346081f shopbasket.Item@1346081f asddasdas
shopbasket.Item@4c8bc1d8 shopbasket.Item@4c8bc1d8 asddasdas
shopbasket.Item@7b0d2332 shopbasket.Item@7b0d2332 asddasdas
shopbasket.Item@6e38515f shopbasket.Item@6e38515f asddasdas
shopbasket.Item@4d9daa77 shopbasket.Item@4d9daa77 asddasdas
shopbasket.Item@5f0a371d shopbasket.Item@5f0a371d asddasdas
shopbasket.Item@4d0c8b7d shopbasket.Item@4d0c8b7d asddasdas
shopbasket.Item@6112892a shopbasket.Item@6112892a asddasdas
shopbasket.Item@41fc596d shopbasket.Item@41fc596d asddasdas
shopbasket.Item@4fc03c90 shopbasket.Item@4fc03c90 asddasdas
shopbasket.Item@663e1176 shopbasket.Item@663e1176 asddasdas
shopbasket.Item@13909f42 shopbasket.Item@13909f42 asddasdas
add a comment |
This one:
<tr th:each="prod : ${prods}">
<td th:text="${prod}">sdfsdf</td>
<td th:text="${prod}">asdasd</td>
<td>asddasdas</td>
</tr>
gives output:
shopbasket.Item@10d9f966 shopbasket.Item@10d9f966 asddasdas
shopbasket.Item@1346081f shopbasket.Item@1346081f asddasdas
shopbasket.Item@4c8bc1d8 shopbasket.Item@4c8bc1d8 asddasdas
shopbasket.Item@7b0d2332 shopbasket.Item@7b0d2332 asddasdas
shopbasket.Item@6e38515f shopbasket.Item@6e38515f asddasdas
shopbasket.Item@4d9daa77 shopbasket.Item@4d9daa77 asddasdas
shopbasket.Item@5f0a371d shopbasket.Item@5f0a371d asddasdas
shopbasket.Item@4d0c8b7d shopbasket.Item@4d0c8b7d asddasdas
shopbasket.Item@6112892a shopbasket.Item@6112892a asddasdas
shopbasket.Item@41fc596d shopbasket.Item@41fc596d asddasdas
shopbasket.Item@4fc03c90 shopbasket.Item@4fc03c90 asddasdas
shopbasket.Item@663e1176 shopbasket.Item@663e1176 asddasdas
shopbasket.Item@13909f42 shopbasket.Item@13909f42 asddasdas
add a comment |
This one:
<tr th:each="prod : ${prods}">
<td th:text="${prod}">sdfsdf</td>
<td th:text="${prod}">asdasd</td>
<td>asddasdas</td>
</tr>
gives output:
shopbasket.Item@10d9f966 shopbasket.Item@10d9f966 asddasdas
shopbasket.Item@1346081f shopbasket.Item@1346081f asddasdas
shopbasket.Item@4c8bc1d8 shopbasket.Item@4c8bc1d8 asddasdas
shopbasket.Item@7b0d2332 shopbasket.Item@7b0d2332 asddasdas
shopbasket.Item@6e38515f shopbasket.Item@6e38515f asddasdas
shopbasket.Item@4d9daa77 shopbasket.Item@4d9daa77 asddasdas
shopbasket.Item@5f0a371d shopbasket.Item@5f0a371d asddasdas
shopbasket.Item@4d0c8b7d shopbasket.Item@4d0c8b7d asddasdas
shopbasket.Item@6112892a shopbasket.Item@6112892a asddasdas
shopbasket.Item@41fc596d shopbasket.Item@41fc596d asddasdas
shopbasket.Item@4fc03c90 shopbasket.Item@4fc03c90 asddasdas
shopbasket.Item@663e1176 shopbasket.Item@663e1176 asddasdas
shopbasket.Item@13909f42 shopbasket.Item@13909f42 asddasdas
This one:
<tr th:each="prod : ${prods}">
<td th:text="${prod}">sdfsdf</td>
<td th:text="${prod}">asdasd</td>
<td>asddasdas</td>
</tr>
gives output:
shopbasket.Item@10d9f966 shopbasket.Item@10d9f966 asddasdas
shopbasket.Item@1346081f shopbasket.Item@1346081f asddasdas
shopbasket.Item@4c8bc1d8 shopbasket.Item@4c8bc1d8 asddasdas
shopbasket.Item@7b0d2332 shopbasket.Item@7b0d2332 asddasdas
shopbasket.Item@6e38515f shopbasket.Item@6e38515f asddasdas
shopbasket.Item@4d9daa77 shopbasket.Item@4d9daa77 asddasdas
shopbasket.Item@5f0a371d shopbasket.Item@5f0a371d asddasdas
shopbasket.Item@4d0c8b7d shopbasket.Item@4d0c8b7d asddasdas
shopbasket.Item@6112892a shopbasket.Item@6112892a asddasdas
shopbasket.Item@41fc596d shopbasket.Item@41fc596d asddasdas
shopbasket.Item@4fc03c90 shopbasket.Item@4fc03c90 asddasdas
shopbasket.Item@663e1176 shopbasket.Item@663e1176 asddasdas
shopbasket.Item@13909f42 shopbasket.Item@13909f42 asddasdas
answered Nov 17 '18 at 8:42
gralucgraluc
6110
6110
add a comment |
add a comment |
try this form instead : <td th:inline="text">[[${prod.price}]]</td>
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
add a comment |
try this form instead : <td th:inline="text">[[${prod.price}]]</td>
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
add a comment |
try this form instead : <td th:inline="text">[[${prod.price}]]</td>
try this form instead : <td th:inline="text">[[${prod.price}]]</td>
answered Nov 24 '18 at 4:25
NesrynaNesryna
84
84
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
add a comment |
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
after reading the other comments i figured that code worked in another environment but you still can't get it to work in yours ...i had the same issue and i solved it by matching my JDK and my JRE cuz my java did an upgrade on its own ..so try setting that first :) break a leg !! @graluc
– Nesryna
Nov 24 '18 at 4:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53335986%2fthymeleaf-springel-expression%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
is it possible that prod.itemName is null?
– Clomez
Nov 16 '18 at 10:32
I think it can't be null
– graluc
Nov 16 '18 at 10:34
Are you certain that you have all the getters and setters for the class? im looking at the exact same code overhere, and its working :/
– Clomez
Nov 16 '18 at 10:36
Just a guess...
prod: ${product}- Assuming that everything else is actually ok, could it be that you need a whitespace before the colon, likeprod : ${product}? Almost every snippet online has that whitespace, even the tutorial you linked does. Maybe that's the issue here– BackSlash
Nov 16 '18 at 10:45
1
The type of
prodprobably isn't what you think it is. Output just${prod}in the loop and see what class ThymeLeaf tells you it is and proceed from there.– Metroids
Nov 16 '18 at 15:54