【问题标题】:Remove double quotes from a string in velocity template从速度模板中的字符串中删除双引号
【发布时间】:2014-08-07 16:06:18
【问题描述】:

输入是:var={cost=7022.61, marker=down, month=AUGUST, totalCost=17147.52}

代码是:

<table>
    <tr>
        <td>ESTIMATE FOR $var.month $var.cost</td>
    </tr>
    <tr>
        <td>Spent Last Month $var.totalCost</td>
    </tr>
</table>

输出:估计为“AUGUST”“7022.61”
上个月花费“17147.52”

预期输出:估计 8 月 7022.61
上个月花费 17147.52

【问题讨论】:

    标签: java html velocity


    【解决方案1】:

    我遇到了同样的问题。

    我是这样解决的(速度1.7)

    <table>
        <tr>
            <td>ESTIMATE FOR $!{var.month.replace('"',"")} $!{var.cost.replace('"',"")}</td>
        </tr>
        <tr>
            <td>Spent Last Month $!{var.totalCost.replace('"',"")}</td>
        </tr>
    </table>
    

    我希望我已经为您提供了有关您问题的所有答案。

    【讨论】:

    • 我将 $var.month 替换为 $!{var.month.replace('"',"")} 但这次它没有打印任何内容。
    • 如果 var.month 为空,则不打印任何内容,因为有 '!'
    • 任何其他解决方案都对我不起作用,因为我希望双引号成为我价值的一部分
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    • 2012-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多