Calling class methods (static) from inside a velocity view page

前端 未结 2 1822
天命终不由人
天命终不由人 2020-12-10 10:47

Can you call class methods from inside a view page?

Specifically ones that are not passed into the view?

In asp.net MVC I can do this:

<         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 11:51

    Here is a universal way to call any static method of any class without need for preliminarily context manipulation:

    #‌​set($str='test')##
    #set($Base64=$str.class.forName('java‌​.util.Base64'))##
    ​$Base64.getEncoder()‌​.encodeToString($str‌​.getBytes('utf8'))
    

提交回复
热议问题