写个宏
setCase.ftl:
<#assign FORM_TEXT = "单行文本"/> <#assign FORM_MULTI_TEXT = "多行文本"/> <#assign FORM_DATE_TEXT = "日期"/> <#assign FORM_CURRENCY_TEXT = "货币"/> <#assign FORM_NUMBER = "数值"/> <#assign FORM_FLOAT_TEXT = "浮点数值"/> <#assign FORM_INTEGER_TEXT = "整型数值"/> <#assign FORM_CHOICE = "选择"/> <#assign FORM_SELECT = "下拉列表"/> <#assign FORM_CHECKBOX = "多选"/> <#assign FORM_RADIO = "单选"/> <#assign FORM_UNNKOWN_TEXT = "未知"/> <#assign URI_FORM_TEXT_U = "customerform2/updateTextColumnInit"/> <#assign URI_FORM_MULTI_TEXT_U = "customerform/updateTextFieldColumnInit"/> <#assign URI_FORM_DATE_TEXT_U = "customerform/updateDateColumnInit"/> <#assign URI_FORM_NUMBER_U = "customerform/updateNumberColumnInit"/> <#assign URI_FORM_CURRENCY_TEXT_U = "customerform/updateCurrencyColumnInit"/> <#assign URI_FORM_CHOICE_U = "customerform2/updateChoiceColumnInit"/> <#assign URI_FORM_TEXT_D = "customerform2/deleteTextColumn"/> <#assign URI_FORM_MULTI_TEXT_D = "customerform/deleteTextFieldColumn"/> <#assign URI_FORM_DATE_TEXT_D = "customerform/deleteDateColumn"/> <#assign URI_FORM_NUMBER_D = "customerform/deleteNumberColumn"/> <#assign URI_FORM_CURRENCY_TEXT_D = "customerform/deleteCurrencyColumn"/> <#assign URI_FORM_CHOICE_D = "customerform2/deleteChoiceColumn"/> <#macro typeCase type> <#if type==formConstants.FORM_TEXT> ${FORM_TEXT} <#elseif type==formConstants.FORM_MULTI_TEXT> ${FORM_MULTI_TEXT} <#elseif type==formConstants.FORM_DATE_TEXT> ${FORM_DATE_TEXT} <#elseif type==formConstants.FORM_CURRENCY_TEXT> ${FORM_CURRENCY_TEXT} <#elseif type==formConstants.FORM_NUMBER> ${FORM_NUMBER} <#elseif type==formConstants.FORM_FLOAT_TEXT> ${FORM_FLOAT_TEXT} <#elseif type==formConstants.FORM_INTEGER_TEXT> ${FORM_INTEGER_TEXT} <#elseif type==formConstants.FORM_CHOICE> ${FORM_CHOICE} <#elseif type==formConstants.FORM_CHECKBOX> ${FORM_CHECKBOX} <#elseif type==formConstants.FORM_SELECT> ${FORM_SELECT} <#elseif type==formConstants.FORM_RADIO> ${FORM_RADIO} <#else> ${FORM_UNNKOWN_TEXT} </#if> </#macro> <#macro typeURICase type> <#if type==(formConstants.FORM_TEXT+"U")> ${URI_FORM_TEXT_U} <#elseif type==(formConstants.FORM_MULTI_TEXT+"U")> ${URI_FORM_MULTI_TEXT_U} <#elseif type==(formConstants.FORM_DATE_TEXT+"U")> ${URI_FORM_DATE_TEXT_U} <#elseif type==(formConstants.FORM_CURRENCY_TEXT+"U")> ${URI_FORM_CURRENCY_TEXT_U} <#elseif type==(formConstants.FORM_NUMBER+"U") || type==(formConstants.FORM_FLOAT_TEXT+"U") || type==(formConstants.FORM_INTEGER_TEXT+"U")> ${URI_FORM_NUMBER_U} <#elseif type==(formConstants.FORM_CHOICE+"U") || type==(formConstants.FORM_CHECKBOX+"U") || type==(formConstants.FORM_SELECT+"U") || type==(formConstants.FORM_RADIO+"U")> ${URI_FORM_CHOICE_U} <#elseif type==(formConstants.FORM_TEXT+"D")> ${URI_FORM_TEXT_D} <#elseif type==(formConstants.FORM_MULTI_TEXT+"D")> ${URI_FORM_MULTI_TEXT_D} <#elseif type==(formConstants.FORM_DATE_TEXT+"D")> ${URI_FORM_DATE_TEXT_D} <#elseif type==(formConstants.FORM_CURRENCY_TEXT+"D")> ${URI_FORM_CURRENCY_TEXT_D} <#elseif type==(formConstants.FORM_NUMBER+"D") || type==(formConstants.FORM_FLOAT_TEXT+"D") || type==(formConstants.FORM_INTEGER_TEXT+"D")> ${URI_FORM_NUMBER_D} <#elseif type==(formConstants.FORM_CHOICE+"D") || type==(formConstants.FORM_CHECKBOX+"D") || type==(formConstants.FORM_SELECT+"D") || type==(formConstants.FORM_RADIO+"D")> ${URI_FORM_CHOICE_D} <#else> </#if> </#macro>
在模板页面中使用:
<#include "/macros/setCase.ftl"/> <@typeURICase type=("type参数"+'U')/> <@typeCase type="type参数"/>