javax.servlet.ServletException: Cannot expose bind macro helper 'springMacroRequestContext' because of an existing model object of the same name
还有
freemarker.core.NonSequenceOrCollectionException: The value you try to list is an extended_hash+string (com.baomidou.mybatisplus.plugins.Page wrapped into f.e.b.StringModel), thus you must specify two loop variables after the "as"; one for the key, and another for the value, like <#... as k, v>).
项目是springboot+freemark
今天报了这个错 ,先来解释下为什么报错
根据错误提示在[#list indexPage as _data]
遍历集合时候出错了, 再看后台怎么封装的
Page<IrStaticDiss> indexPage = iIrStaticDissService.searchIndexByVo(irStaticDissVo);
model.addAttribute("indexPage", indexPage);
这里是直接将查出Page返回了 (Page是mybatis-plus自带的) , 所以应该再取值时改成下面这样就不会报错了
[#list indexPage.records as _data]
粗心的错…
SpringBoot+FreeMarker遍历集合报错解析
本文记录了一次在SpringBoot项目中使用FreeMarker模板引擎时遇到的错误,具体表现为在遍历集合时出现异常。错误源于从Mybatis-Plus查询的Page对象直接返回,正确做法是取出Page内的数据后再传递给FreeMarker模板,以避免此类错误。
4765

被折叠的 条评论
为什么被折叠?



