首页 技术 正文
技术 2022年11月17日
0 收藏 894 点赞 4,468 浏览 7282 个字

http://www.cnblogs.com/zengxlf/archive/2009/05/06/1451004.html

加载foot模块页
#parse(“foot.vm”)

#foreach($item in $tables)
 #set($strEnd = $item.Length – 1)
 #set($sheetName = $item.Substring(0, $strEnd))
 <option value=”$item”>$sheetName</option>
#end

$strEnd也可以看做一个字符串来操作
$item.Substring(0,15) 取出从0开始的15个字符
——————————————————————————————
//$listType才能用ToString()时,不能用$!{listType}不会出错不能被ToString();
//$listType.toString(‘f2’),四舍五入,保留两小数。toString();可以加很多的参数,查查参数表.
#if($listType.ToString() == “List”)
 #foreach($item in $items)
 <li><a href=”FindByPosition.page?positionId=$!{item.Id}”>$!{item.PositionName}</a></li>
 #end
#elseif($listType.ToString() == “Select”)
 <select id=”position” name=”employee.Position”>
 <option value=”-1″>请选择</option>
 #foreach($item in $items)
 <option value=”$!{item.Id}”>$!{item.PositionName}</li>
 #end
 </select>
#end

//#foreach()的循环用法。
<select id=”sels”>
 #foreach($time in [1..$checkorder.TimeCount])
  <option value=$time>$time</option>
 #end
</select>
—————————————————————————————
2008-1-5:作VTL表达式,Castle工程
VTL表达式不区分大小写,可以调用方法,属性,
//$velocityCount是统计循环的次数,从1弄开始计算
#set($foo=”Holle”) ${foo}world
##:是单行注释。#**#:多行注释。
<table>
#foreach($info in $array)
 <tr>
 <td>$velocityCount ##统计循环的次数从1开始计</td>
 <td>$!{info.name}</td>
 <td>$!{info.Password}</td>
 <td>$!{info.Age}</td>
 <td>$!{info.getvalue}</td>
 </tr>
#end
</table>
循环Hashtable是的用法
$allProducts是Hashtable的对象
#foreach($var in $allProducts)
 ##var.key:获取键 var.value:获取值
 $!{var.key}->$!{var.value}
#end
//另一种Hashtable的循环用法
vm页面用关键字点键名。
<h3>$!{hash.aa}</h3>
<h3>$!{hash.bb}</h3>
<h3>$!{hash.cc}</h3>
<h3>$!{hash.dd}</h3>
Controll层里
public void Index()
{
 Hashtable hash = new Hashtable();
 hash.Add(“aa”,”one”);
 hash.Add(“bb”,DateTime.MaxValue);
 hash.Add(“cc”,DateTime.MinValue);
 hash.Add(“dd”,DateTime.Now.ToString());
}
————————————————————————————-
##是可以用来输出字面的意思是原样输出(注释用的)
#literal()
#foreach($woogie in $boogie)
 nothing will happen to $woogie
#end
#end
—————————————————————————————–
//$type里面的一些方法,比较有用。
#if($type.ToLower() != “noservice”)  ToLower():是小写字符串的方法。
ToString():
#set($index=$item.Content.IndexOf(“,”))
$!{item.ReceiveTime.ToString(“yyyy-mm-dd HH:mm”)}
$!{consumeLog.OperateDate.ToString(“yyyy-MM-dd HH:mm”)}
$!{consume.ConsumeDate.ToString(“d”)}
$!{consume.ConsumeDate.ToString(“t”)}
$!{sign.FirstStartTime.ToShortDateString()}与$!{sign.FirstStartTime.ToString(“yyyy-MM-dd”)}效果一样的。
#set($index = $customer.IndexOf(“,”))取得逗号位置
$r.Phone.Substring(0,7)****:取出电话号码为:1371093****
—————————————————————————————–
this.ProprtBag.Add(“time”,DateTime.Now);
//用来判断是否为空
#if($time!=””)
 <h1>$!time</h1>
#end
//当有数组是判断是否是数
#if($items.Count>0)
 #foreach($item in $items)
  $!{item}
 #end
#end
—————————————————————————————–
#elseif:多重条件判断
#if(!$order)
 100001
#elseif($order.CustomerId && $order.CustomerId != “” && $order.CustomerId != $userName)
 100002
#elseif($order && ($order.CustomerId == “” || !$order.CustomerId || $order.CustomerId == $userName))
 100003
#end
—————————————————————————————————–
用<!–  –>:来注释页面上用的,不能有套用会无法注释的如:<!– <!– –> –>
———————————————————————————————————
//会依次显示,当翻页面时也会接着上一页继续显示编号。其中14为每一页显示的条数,根据需要而调整
#if(!$page || $page <= 0)
 #set($page = 1)
#end
#set($rowIndex = ($page – 1) * 14 )
#foreach($log in $logDt.Rows)
 $rowIndex
#end
———————————————————————————————————
$!{consumeLog.OperateDate.ToString(“yyyy-MM-dd HH:mm”)}
———————————————————————————————————
#if(!$log.UserName || $log.UserName == “”)
 <a title=”邀请会员激活空间”
href=”javascript:sendMessage(‘$!{log.CardId}’)”><img alt=”未绑定”
src=”../images/noTies.gif” /></a>
 <div id=”ajaxmsg”></div>
#else
 <a href=”http://$!%7blog.username%7d.i.myking.cn/” target=”_blank”><img alt=”进入TA的个人王国” src=”../images/Ties.gif” /></a>
#end
用来判断为空值时的处理
———————————————————————————————————–
DataTable或者DataSet的页面数据加载。
———————*.vm———————————————————————————-
页面上写的是
#foreach($log in $table.Rows)
 $!{log.Id}>>>$!{log.User}>>>$!{log.Phone}
#end
—————-controller———————————-
public void Index()
{
 DataTable table = new DataTable();
 table.Columns.Add(“Id”,typeof(int));
 table.Columns.Add(“User”,typeof(string));
 table.Columns.Add(“Phone”,typeof(string));
 for(int i=0;i<3;i++)
 {
  DataRow row = table.NewRow();
  row[“Id”]=i;
  row[“User”]=”cheng”;
  row[“Phone”]=”2222222″;
  table.Rows.Add(row);
 }
 this.ProperBag.Add(“table”,table);
}
—————————-DateSet数据绑定页面————————————
#foreach($t in $ds.Tables)
 <table class=”month”>
 <tr>
  #foreach($col in $t.Columns)
   <th>$col.ColumnName.Replace(“日”,””)</th>
  #end
 <tr>
 #foreach($r in $t.Rows)
 <tr>
  #foreach($c in $r.ItemArray)
   <td align=”center”>
   #if($c==0)–#end
  #if($c>0) $c.ToString() #end</td>
 #end
 </tr>
 #end
 </table>
#end
———————后台的代码—————————————————-
using(DataSet ds=_cardsSituation.ByCardType(CurrentMerchant.UserName,year,month))
{
 PropertyBag.Add(“ds”,ds);
}
————————————————————————————-
//时间日期的判断
#if($!{Member.Isusedate.ToShortDateString()} ==”0001-1-1″)
 —-
#else
 $!{Member.Isusedate.ToShortDateString()}
#end
————————————————————————————-
//用于计算剩余的值
#set($Balance = $!item.Money – $!item.FactMoney)
<td  class=”last”>$Balance.toString(‘f2’)</td>
————————————————————————————-
//用来显示DataTable dt类型数据的方法。
#foreach($col in $dt.Columns)
 <th>$col.ColumnName</th>
#end
<tr>
#foreach($dr in $dt.Rows)
 <tr>
 #foreach($c in $dr.ItemArray)
  <td align=”center”>
  #if(!$c || $c.ToString()==”” || $c.ToString()==”0″)
  —
  #else
  $c.ToString()
  #end</td>
 #end
 </tr>
#end

————————————————————————————–

———————*.vm————————————
页面上写的是
#foreach($log in $table.Rows)
 $!{log.Id}>>>$!{log.User}>>>$!{log.Phone}
#end
—————-controller———————————-
public void Index()
{
 DataTable table = new DataTable();
 table.Columns.Add(“Id”,typeof(int));
 table.Columns.Add(“User”,typeof(string));
 table.Columns.Add(“Phone”,typeof(string));
 for(int i=0;i<3;i++)
 {
  DataRow row = table.NewRow();
  row[“Id”]=i;
  row[“User”]=”cheng”;
  row[“Phone”]=”2222222″;
  table.Rows.Add(row);
 }
 this.ProperBag.Add(“table”,table);
}

—————————-DateSet数据绑定页面—————————————————–
#foreach($t in $ds.Tables)
  <table class=”month”>
  <tr>
  #foreach($col in $t.Columns)
   <th>$col.ColumnName.Replace(“日”,””)</th>
  #end
  <tr>
  #foreach($r in $t.Rows)
   <tr>
   #foreach($c in $r.ItemArray)
    <td align=”center”>
    #if($c==0)–#end
    #if($c>0) $c.ToString() #end</td>
   #end
   </tr>
  #end
  </table>
 #end
———————后台的代码
using(DataSet ds=_cardsSituation.ByCardType(CurrentMerchant.UserName,year,month))
{
 PropertyBag.Add(“ds”,ds);
}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905