freemarker 中不能这么写么

fenghen 2009-02-13 12:01:05

我想在显示文章列表的时候没有审核的不显示
arti.auditing 为布尔值

<#if ${arti.auditing}>

这样写报错

在其他地方单下面这也写也报错。。。如果arti.auditing为其他类型的话就不会报错
${arti.auditing}


哪位给解释下。。

谢谢了
...全文
682 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hp5212000 2009-02-13
  • 打赏
  • 举报
回复
这样试试 <#if arti.auditing> ....</#if>
fenghen 2009-02-13
  • 打赏
  • 举报
回复
没人哦。。。。
fenghen 2009-02-13
  • 打赏
  • 举报
回复
再次感谢
hp5212000 2009-02-13
  • 打赏
  • 举报
回复
-_-!!!
fenghen 2009-02-13
  • 打赏
  • 举报
回复
晕。。。。以前写错的<#if arti.auditing> 一直没删。。。。好像现在好了。。。

谢谢你了。。。。。哈哈
fenghen 2009-02-13
  • 打赏
  • 举报
回复
<#macro artiList i j=20>

<#assign n = 0/>
<#list articleList[i] as arti>
<#if arti.auditing>
<#assign n = n+1 />
<#if n lte j>
<li><a href="${arti.url?default("")}">${arti.title?default("")}</a>
${arti.auditing}
</#if>
</#if>
</#list>

</#macro>
fenghen 2009-02-13
  • 打赏
  • 举报
回复
哎。。。但是还是报错


Expecting a string, date or number here, Expression arti.auditing is instead a freemarker.template.TemplateBooleanModel$2
hp5212000 2009-02-13
  • 打赏
  • 举报
回复
对啊 如果你定义的auding是布尔型的 <#if arti.auding>....</#if> 应该是没问题的
fenghen 2009-02-13
  • 打赏
  • 举报
回复
恩。。。我在数据库中定义的是布尔型的。。。。我现在不能改字段类型 。布尔型的怎么比较呢。。。。可能我比较笨。。呵呵


<#if arti.auding>............</if>
hp5212000 2009-02-13
  • 打赏
  • 举报
回复
你得保证左右的类型一致啊 要么都是string 要么都是int 那样才能比较啊 你在类中定义auditing是string的话 就可以这样比较啊 <#if arti.auditing == ’true‘ > .... </#if> 如果是int的 那就用int的比较
fenghen 2009-02-13
  • 打赏
  • 举报
回复
谢谢你

这样还是报错。。看。。。。。。。。。。先说下数据库位mysql。。。auditing这个字段在数据库默认为1.。。。审核后为0

The only legal comparisons are between two numbers, two strings, or two dates.
Left hand operand is a freemarker.template.TemplateBooleanModel$1
Right hand operand is a freemarker.template.SimpleNumber
hp5212000 2009-02-13
  • 打赏
  • 举报
回复
照理说应该可以 具体不清楚你怎么样的了 那你就用string型判断等于“true” 或 “false” 来解决了 <#if arti.auditing == ’true‘ > .... </#if>
fenghen 2009-02-13
  • 打赏
  • 举报
回复
那样写不行。。。提示那个没定义

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧