【发布时间】:2018-03-31 18:33:19
【问题描述】:
我正在使用速度模板来生成电子邮件模板,在这里我想为每个“标签”创建表格,并将各自的值作为表格数据。
我正在传递一个列表标签,其中包含标签的详细信息,包括 tagName,我使用它为每个标签传递相应的列表。 (如果 tagName = "test",我将测试表的数据作为 $test 传递)
如图所示,我已将每个表的数据设置为 $arrayobjs,但该表不显示行,因为我认为它不会遍历 $arrayobs。请帮我遍历数据并将数据设置为列。
P.S.-虽然我可以打印 $tags[0] 的值 , $arrayobjs[0] 不打印值
#set ($d = '$')
#foreach($tag in $tags)
#set ($var = "${d}${tag.tagName}")
#set ($arrayobjs = "#evaluate($var)")
<table style='width:600px; padding-left: 11px; font:Segoe UI;'>
<tr>
<td> <span style='font-size: 17px; font-weight: 400; font-family:Georgia;'>$tag.tagName </span></td>
</tr>
</table>
<br>
<table width=583 style='width:437.5pt; margin-left:8.25pt;border-collapse:collapse;font-family:"Segoe UI",sans-serif;'>
<tr style='vertical-align:top;height:10px;'>
<td width=50px style='border:solid white 1.0pt;background: #a3a3c2;padding:1pt 1pt 1pt 1pt;'>
<p> <span style='font-size:10.0pt;color:#3d3d5c;'><b>COL1</b></span> <span style='font-size:9.0pt;color:#404040'> <br><b></b> </span> </p>
</td>
<td width=100px style='border:solid white 1.0pt;background: #a3a3c2;padding:1pt 1pt 1pt 1pt;'>
<p> <span style='font-size:10.0pt;color:#3d3d5c'><b>COL2</b></span> <span style='font-size:9.0pt;color:#404040'> <br><b></b> </span> </p>
</td>
<td width=50px style='border:solid white 1.0pt;background: #a3a3c2;padding:1pt 1pt 1pt 1pt;'>
<p> <span style='font-size:10.0pt;color:#3d3d5c'><b>COL3</b></span> <span style='font-size:9.0pt;color:#404040'> <br><b></b> </span> </p>
</td>
<td width=50px style='border:solid white 1.0pt;background: #a3a3c2;padding:1pt 1pt 1pt 1pt;'>
<p> <span style='font-size:10.0pt;color:#3d3d5c'><b>COL4</b></span> <span style='font-size:9.0pt;color:#404040'> <br><b></b> </span> </p>
</td>
<td width=50px style='border:solid white 1.0pt;background: #a3a3c2;padding:1pt 1pt 1pt 1pt;'>
<p> <span style='font-size:10.0pt;color:#3d3d5c'><b>COL5</b></span> <span style='font-size:9.0pt;color:#404040'> <br><b></b> </span> </p>
</td>
<td width=50px style='border:solid white 1.0pt;background: #a3a3c2;padding:1pt 1pt 1pt 1pt;'>
<p> <span style='font-size:10.0pt;color:#3d3d5c'><b>COL6</b></span> <span style='font-size:9.0pt;color:#404040'> <br><b></b> </span> </p>
</td>
</tr>
#foreach($o in $arrayobjs)
<tr style='vertical-align:top;height:5px;'>
<td width=50px style='border:solid white 1.0pt;background: #f0f0f5;padding:0.5pt 0.5pt 0.5pt 0.5pt;'>
<p> <span style='font-size:9.0pt;color:#7F7F7F'></span> <span style='font-size:9.0pt;color:#404040'>$o.col1 </span> </p>
</td>
<td width=180px style='border:solid white 1.0pt;background: #f0f0f5;padding:0.5pt 0.5pt 0.5pt 0.5pt;'>
<p> <span style='font-size:9.0pt;color:#7F7F7F'></span> <span style='font-size:9.0pt;color:#404040'>$o.col2</span> </p>
</td>
<td width=30px style='border:solid white 1.0pt;background: #f0f0f5;padding:0.5pt 0.5pt 0.5pt 0.5pt;'>
<p> <span style='font-size:9.0pt;color:#7F7F7F'></span> <span style='font-size:9.0pt;color:#404040'>$o.col3</span> </p>
</td>
<td width=30px style='border:solid white 1.0pt;background: #f0f0f5;padding:0.5pt 0.5pt 0.5pt 0.5pt;'>
<p> <span style='font-size:9.0pt;color:#7F7F7F'></span> <span style='font-size:9.0pt;color:#404040'>$o.col4</span> </p>
</td>
<td width=30px style='border:solid white 1.0pt;background: #f0f0f5;padding:0.5pt 0.5pt 0.5pt 0.5pt;'>
<p> <span style='font-size:9.0pt;color:#7F7F7F'></span> <span style='font-size:9.0pt;color:#404040'>$o.col5</span> </p>
</td>
<td width=30px style='border:solid white 1.0pt;background: #f0f0f5;padding:0.5pt 0.5pt 0.5pt 0.5pt;'>
<p> <span style='font-size:9.0pt;color:#7F7F7F'></span> <span style='font-size:9.0pt;color:#404040'>$o.col6</span> </p>
</td>
</tr>
#end
</table>
#end
【问题讨论】:
-
$arrayobjs和$arrayobjs.class.name的输出是什么? -
$arrayobjs 输出对象的完整列表。 $arrayobjs.class.name 输出字符串
标签: velocity