Html 如何在freeMarker中动态访问指定的变量 ${transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code} transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code=这将输出U/B/M/F。我想使用此输出并访问相应的分配变量 例如,如果transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code返回U,我希望访问分配的变量并获取U的值,该值为“未知”。我怎样才能在Freemarker中做到这一点

Html 如何在freeMarker中动态访问指定的变量 ${transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code} transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code=这将输出U/B/M/F。我想使用此输出并访问相应的分配变量 例如,如果transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code返回U,我希望访问分配的变量并获取U的值,该值为“未知”。我怎样才能在Freemarker中做到这一点,html,apache,html-email,freemarker,email-templates,Html,Apache,Html Email,Freemarker,Email Templates,您可以像.vars[myDynamicVariableName]那样执行此操作,但是,您可能不需要这样做。您可以只使用,然后使用codeToLabel[myDynamicCode] <#assign U="Unknown" B="both" M="male" F="female"> <div> <span> ${transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code}

您可以像
.vars[myDynamicVariableName]
那样执行此操作,但是,您可能不需要这样做。您可以只使用
,然后使用
codeToLabel[myDynamicCode]

<#assign U="Unknown" B="both" M="male" F="female">

<div>
<span>     ${transaction.addressTransactions.addresses.newInfo.GenderTypeCode.code} </span>
</div>