switch, case, default, break

语法
<#switch value>
  <#case refValue1>
    ...
    <#break>
  <#case refValue2>
    ...
    <#break>
  ...
  <#case refValueN>
    ...
    <#break>
  <#default>
    ...
< /#switch>

用例
字符串
<#switch being.size>
  <#case "small">
     This will be processed if it is small
     <#break>
  <#case "medium">
     This will be processed if it is medium
     <#break>
  <#case "large">
     This will be processed if it is large
     <#break>
  <#default>
     This will be processed if it is neither
< /#switch>
数字
<#switch x>
  <#case x = 1>
    1
  <#case x = 2>
    2
  <#default>
    d
< /#switch>

如果x=1 输出 1 2, x=2输出 2, x=3 输出d

原文地址:https://www.cnblogs.com/zifashaonian10000/p/4218628.html