NVelocity 经验

   这几天在结合NVelocity做一个UI模版定制,在cs中put的数据是变化的,我主要是通过一个xml文件来配置后台输出的数据,通过反射调用该接口方法来实现输出。

   在UI 中有几个小经验。

   1.输出辅助类

   后台put出的结果集往往需要一个辅助类进一步处理,比如字符串截取等。

   可以通过如下方法实现:

  th.Put("helper", new NameUrl());

 

   UI调用:

$helper.FilterUrl($ProductName,"-")

   2.调用的时候字符串连接的处理

  

#foreach($item in $BottomSiteInfoList)
<a href="${helper.FilterUrl($item.InfoTitle,"-")}.html" title='$item.InfoTitle' >$item.InfoTitle</a> :: 
#end

  3.foreach中循环判断

  

#foreach($item in $TopNumTagList)
 #if ($item.isBlod=="1")
<strong><a href="popular/$helper.FilterUrl($item.HotTag,"-")/">$item.HotTag</a></strong>,
#else
<a href="popular/$helper.FilterUrl($item.HotTag,"-")/">$item.HotTag</a>,
#end      
#end

   

posted @ 2011-02-28 19:16  clound  阅读(623)  评论(0编辑  收藏  举报