Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "activity['activityId']" (template: "workbench/activity/test2" - line 12, col 17)
at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.attoparser.MarkupParser.parse(MarkupParser.java:257) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
... 48 common frames omitted
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "activity['activityId']" (template: "workbench/activity/test2" - line 12, col 17)
org.springframework.expression.spel.SpelEvaluationException: EL1027E: Indexing into type 'com.zarek.crm.pojo.domain.Activity' is not supported
Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: “activity[‘activityId’]” (template: “workbench/activity/test2” - line 12, col 17)
org.springframework.expression.spel.SpelEvaluationException: EL1027E: Indexing into type ‘com.zarek.crm.pojo.domain.Activity’ is not supported
由于我的实体类和mapper映射文件是使用mybatis generator生成的,
导致原本我数据库中的表的属性是 activityId (I 是大写的) 的,结果实体类成了 activityid(i 是小写的)
mapper文件中,mybatis generator自动给我产生了一个BaseResultMap对应,我没有注意。
<resultMap id="BaseResultMap" type="com.zarek.crm.pojo.domain.Activity" >
<id column="activityId" property="activityid" jdbcType="CHAR" />
<result column="owner" property="owner" jdbcType="CHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="startDate" property="startdate" jdbcType="CHAR" />
<result column="endDate" property="enddate" jdbcType="CHAR" />
<result column="cost" property="cost" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="createTime" property="createtime" jdbcType="CHAR" />
<result column="createBy" property="createby" jdbcType="VARCHAR" />
<result column="editTime" property="edittime" jdbcType="CHAR" />
<result column="editBy" property="editby" jdbcType="VARCHAR" />
</resultMap>
因此在进行thymeleaf前端绑定数据的时候,想当然的将其写成了
<td th:text="${activity['activityId']}"></td>
实际上应该写成实体类中定义的属性名
<td th:text="${activity['activityid']}"></td>
因篇幅问题不能全部显示,请点此查看更多更全内容