架构师

您现在的位置是:首页 > 技术博客 > 爱运维

爱运维

An error happened during template parsing

架构师小跟班 2020-06-23 爱运维
工作中有时候会用到一些开源脚手架,但是这些脚手架也不是可以完全信赖的。今天就遇到一个。报错信息:详细报错信息:===========================start========================

工作中有时候会用到一些开源脚手架,但是这些脚手架也不是可以完全信赖的。

今天就遇到一个。

报错信息:

详细报错信息:

===========================start=======================================

11:51:51 [http-nio-8082-exec-10] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][http-nio-8082-exec-10] 

Exception processing template "dorm/fee/edit": An error happened during template parsing (template: "class path resource [templates/dorm/fee/edit.html]")

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/dorm/fee/edit.html]")

at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241)

at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100)

at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666)

        。。。。。。

Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "fee.ID" (template: "dorm/fee/edit" - line 12, col 50)

at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)

at org.attoparser.MarkupParser.parse(MarkupParser.java:257)

at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)

... 69 common frames omitted

Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "fee.ID" (template: "dorm/fee/edit" - line 12, col 50)

at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:290)

at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:165)

at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)

at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)

。。。。。。

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'ID' cannot be found on object of type 'com.jiagou.dorm.domain.FeeDO' - maybe not public or not valid?

at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217)

at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104)

at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:51)

at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:407)

        。。。。。。

==========================end=================================

前端代码:

<form class="form-horizontal m-t" id="signupForm">
   <input id="ID" name="ID" th:value="${fee.ID}" type="hidden">
   <div class="form-group">
       <label class="col-sm-3 control-label">水费:</label>
       <div class="col-sm-8">
           <input id="waterFee" name="waterFee" th:value="${fee.waterFee}" class="form-control"
                  type="text">
       </div>
   </div>

问题原因:

页面找不到ID这个属性,后台接口返回的数据中id这个属性是小写的,但是前端页面中解析的是大写的ID。

解决办法:

页面和后端接口的属性值大小写一致即可。切记!thymeleaf在解析页面的时候是区分大小写的!

文章评论