码迷,mamicode.com
首页 > 其他好文 > 详细

freemarker中的left_pad和right_pad

时间:2014-06-01 15:30:50      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:freemarker   left_pad   right_pad   

freemarker中的left_pad和right_pad


1、简易说明

(1)left_pad 距左边

(2)right_pad 距右边

(3)当仅仅只有一个参数时,插入的是空白;当有两个参数时,插入的是第二个参数符号;如果第二个参数的长度大于1的话,会周期性地插入该符号


2、举例说明

<#--freemarker中的left_pad 距左边-->
     [${""?left_pad(8)}]
     [${"E"?left_pad(8)}]
     [${"EF"?left_pad(8)}]
     [${"EFG"?left_pad(8)}]
     [${"EFGH"?left_pad(8)}]
     [${"EFGHI"?left_pad(8)}]
     [${"EFGHIJ"?left_pad(8)}]
     [${"EFGHIJK"?left_pad(8)}]
     [${"EFGHIJKL"?left_pad(8)}]
     
     [${""?left_pad(8,"*")}]
     [${"E"?left_pad(8,"*")}]
     [${"EF"?left_pad(8,"*")}]
     [${"EFG"?left_pad(8,"*")}]
     [${"EFGH"?left_pad(8,"*")}]
     [${"EFGHI"?left_pad(8,"*")}]
     [${"EFGHIJ"?left_pad(8,"*")}]
     [${"EFGHIJK"?left_pad(8,"*")}]
     [${"EFGHIJKL"?left_pad(8,"*")}]
     
     [${""?left_pad(8,"?*?")}]
     [${"E"?left_pad(8,"?*?")}]
     [${"EF"?left_pad(8,"?*?")}]
     [${"EFG"?left_pad(8,"?*?")}]
     [${"EFGH"?left_pad(8,"?*?")}]
     [${"EFGHI"?left_pad(8,"?*?")}]
     [${"EFGHIJ"?left_pad(8,"?*?")}]
     [${"EFGHIJK"?left_pad(8,"?*?")}]
     [${"EFGHIJKL"?left_pad(8,"?*?")}]
     
     <#--freemarker中的right_pad 距右边-->
     [${""?right_pad(8)}]
     [${"E"?right_pad(8)}]
     [${"EF"?right_pad(8)}]
     [${"EFG"?right_pad(8)}]
     [${"EFGH"?right_pad(8)}]
     [${"EFGHI"?right_pad(8)}]
     [${"EFGHIJ"?right_pad(8)}]
     [${"EFGHIJK"?right_pad(8)}]
     [${"EFGHIJKL"?right_pad(8)}]
     
     [${""?right_pad(8,"*")}]
     [${"E"?right_pad(8,"*")}]
     [${"EF"?right_pad(8,"*")}]
     [${"EFG"?right_pad(8,"*")}]
     [${"EFGH"?right_pad(8,"*")}]
     [${"EFGHI"?right_pad(8,"*")}]
     [${"EFGHIJ"?right_pad(8,"*")}]
     [${"EFGHIJK"?right_pad(8,"*")}]
     [${"EFGHIJKL"?right_pad(8,"*")}]
     
     [${""?right_pad(8,"?*?")}]
     [${"E"?right_pad(8,"?*?")}]
     [${"EF"?right_pad(8,"?*?")}]
     [${"EFG"?right_pad(8,"?*?")}]
     [${"EFGH"?right_pad(8,"?*?")}]
     [${"EFGHI"?right_pad(8,"?*?")}]
     [${"EFGHIJ"?right_pad(8,"?*?")}]
     [${"EFGHIJK"?right_pad(8,"?*?")}]
     [${"EFGHIJKL"?right_pad(8,"?*?")}]

3、示例结果

     [        ]
     [       E]
     [      EF]
     [     EFG]
     [    EFGH]
     [   EFGHI]
     [  EFGHIJ]
     [ EFGHIJK]
     [EFGHIJKL]
     
     [********]
     [*******E]
     [******EF]
     [*****EFG]
     [****EFGH]
     [***EFGHI]
     [**EFGHIJ]
     [*EFGHIJK]
     [EFGHIJKL]
     
     [?*??*??*]
     [?*??*??E]
     [?*??*?EF]
     [?*??*EFG]
     [?*??EFGH]
     [?*?EFGHI]
     [?*EFGHIJ]
     [?EFGHIJK]
     [EFGHIJKL]
     
     [        ]
     [E       ]
     [EF      ]
     [EFG     ]
     [EFGH    ]
     [EFGHI   ]
     [EFGHIJ  ]
     [EFGHIJK ]
     [EFGHIJKL]
     
     [********]
     [E*******]
     [EF******]
     [EFG*****]
     [EFGH****]
     [EFGHI***]
     [EFGHIJ**]
     [EFGHIJK*]
     [EFGHIJKL]
     
     [?*??*??*]
     [E*??*??*]
     [EF??*??*]
     [EFG?*??*]
     [EFGH*??*]
     [EFGHI??*]
     [EFGHIJ?*]
     [EFGHIJK*]
     [EFGHIJKL]


freemarker中的left_pad和right_pad,布布扣,bubuko.com

freemarker中的left_pad和right_pad

标签:freemarker   left_pad   right_pad   

原文地址:http://blog.csdn.net/you23hai45/article/details/27891121

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!