Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Working with content in thymeleaf?  RSS feed

 
wladimir bandeira
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Through a tutorial able to create a product inclusion using the following html code




this is my project;


https://github.com/wladimirbandeira/casadocodigo/tree/master/casadocodigo


I am having great difficulty in performing the codes I made in JSP to do in thymeleaf.


I made the next attempt at the suggestion proposed;




I would like to make it clear as is the method that loads the form;






And before the change made generated this error on the page;




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

Sun Apr 10 06:48:06 BRT 2016
There was an unexpected error (type=Internal Server Error, status=500).
Could not parse as expression: "preco[${status.index}].valor" (produtos/form:30)




And that was the error message on the console;





org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "preco[${status.index}].valor" (produtos/form:30)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:238) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:79) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:40) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.standard.processor.attr.AbstractStandardSingleAttributeModifierAttrProcessor.getTargetAttributeValue(AbstractStandardSingleAttributeModifierAttrProcessor.java:65) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.attr.AbstractSingleAttributeModifierAttrProcessor.getModifiedAttributeValues(AbstractSingleAttributeModifierAttrProcessor.java:59) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.attr.AbstractAttributeModifierAttrProcessor.processAttribute(AbstractAttributeModifierAttrProcessor.java:62) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.Node.processNode(Node.java:972) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]



He is saying with this error message that it does not recognize this piece of code as a regular expression thymeleaf.







Perhaps the thymeleaf approach to treat index is different from the JSP JSTL.


I found this link


http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#the-springstandard-dialect


and I found this example;





and I tried to do so;





And given that error;



org.springframework.expression.spel.SpelEvaluationException: EL1008Epos 6): Property or field 'rows' cannot be found on object of type 'br.com.casadocodigo.model.TipoPreco[]' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) ~[spring-expression-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) ~[spring-expression-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46) ~[spring-expression-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374) ~[spring-expression-4.2.5.RELEASE.jar:4.2.5.RELEASE]

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haven't used thymaleaf but googling a bit the array access thing looks like (note the underscores before and after ${})



Also you ought to thymaleft tags th: whenever possible
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!