【问题标题】:Use method of custom object class in Apache Velocity templateApache Velocity 模板中自定义对象类的使用方法
【发布时间】:2013-11-05 15:54:47
【问题描述】:

我向 Apache Velocity 模板传递了一个 User 类型的变量(由我创建)。 User 有方法 getUsername() 并且在 Velocity 模板中我使用如下:

#if($user)
<p>
User Created $user.getUsername()
</p>
#end

但输出是User Created $user.getUsername(),而不是预期的User Created Pluto;为什么??你能帮帮我吗?

【问题讨论】:

    标签: java templates velocity


    【解决方案1】:

    这意味着 getUsername() 方法返回的值为 null,或者该方法不存在。

    【讨论】:

    • 你说得对,在某种意义上我是一个反问,但只有这个答案我才注意到真正的问题,谢谢!
    猜你喜欢
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    相关资源
    最近更新 更多