简体   繁体   中英

Velocity Java template failing with Javascript element

I am using velocity templating for generating HTML JS script code. The problem I have is, for below code snippet when I try assigning image source element I encounter error because velocity is treating this as Object indirection. How to I make velocity not to do this?

var img_$MyClass.getID() = new Image();
img_$MyClass.getID().src = "abc.com";

You need to use the formal reference notation :

var img_$MyClass.getID() = new Image();
img_${MyClass.getID()}.src = "abc.com";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM