曾今有一个FreeMarker摆在我面前。 我没有好好珍惜, 遇到了Velocity我才想起失去的美好... 


  需求是把PC网页点击、 手机网页点击、App点击相加得到总点击量显示出来:

$article.hits+$article.wapHits+$article.mobileHits
  理想非常美好, 现实输出的是:Number+Number+Number的一个大字符串(想当年。 用FreeMarker的时候。 加减运算直接上, 而现在...)



  据说须要在+号等四则运算符两側都加上空格。 好吧。 尝试下:

$article.hits + $article.wapHits + $article.mobileHits
  尼玛呀, Velocity就是不识别。 给我照样输出大字符串。 我想起了失去的FreeMarker, 耳边响起了《失去的美好》



  好吧, 那就用究极技能(把运算放到Velocity脚本中进行):

#set($total=$article.hits + $article.wapHits + $article.mobileHits)
                $total

  嗯, 能够了, Commit...



相关文章:

  • 2021-09-16
  • 2021-09-12
  • 2022-02-02
  • 2021-08-02
  • 2021-07-04
  • 2022-12-23
  • 2022-03-01
  • 2021-10-12
猜你喜欢
  • 2022-12-23
  • 2021-09-14
  • 2021-11-08
  • 2021-11-19
  • 2021-09-10
  • 2021-06-16
  • 2022-12-23
相关资源
相似解决方案