问题描述:
我在首页使用:
<@postTag method="listByTagId" tagId="标签 id">
// 返回参数:posts
</@postTag>
实际结果:首页报错,进不去首页!大致错误日志为嵌套错误!
期望结果:能同时使用postTag标签,在首页(想做轮播图效果)达到根据分类显示不同区块的内容。
个人猜想:由于页面有两个posts返回对象,导致参数名冲突,所以报错。
期望帮助:有什么方式,可以达到期望结果
急急急!请问首页能使用自定义postTag标签吗
报错日志:
500
Internal Server Error.
Request processing failed; nested exception is freemarker.core.NonHashException: For "." left-hand operand: Expected a hash, but this has evaluated to a sequence (ArrayList wrapped into f.t.DefaultListAdapter): ==> posts [in template "themes/ppoffice_icarus/layout/widget/slider.ftl" at line 12, column 31] ---- FTL stack trace ("~" means nesting-related): - Failed at: #list posts.content as post [in template "themes/ppoffice_icarus/layout/widget/slider.ftl" at line 12, column 24] - Reached through: #include "layout/widget/slider.ftl" [in template "themes/ppoffice_icarus/index.ftl" at line 6, column 7] ~ Reached through: #nested [in template "themes/ppoffice_icarus/layout/layout.ftl" in macro "layout" at line 84, column 25] ~ Reached through: @layout type="index" title="${options... [in template "themes/ppoffice_icarus/index.ftl" at line 3, column 1] ----
test.ftl:
<#macro testmacro>
<@postTag method="listByTagId" tagId="标签 id">
</@postTag>
</#macro>
index.ftl:
<#import "test.ftl" as test>
<@test.testmacro/>
</#postTag>
参考 Freemarker 的命名空间。