Pergunta

I'm using Velocity through a Java application. The velocity in question looks like this:

#if( $name1 != "" )
    #set($line11 = "<CharStyle:-bold black> ${name1}<CharStyle:>")
#end

And outputs as such:

$r<ParaStyle:-body copy>$line11

The output I see at the end of it all is:

${name1}

I want the value of name1 to be put into the stylization text, instead of the name of the variable. This seems to be how the Velocity specs tell me to do this. ( reference )What am I doing wrong?

Foi útil?

Solução

${name1} will evaluate to the literal string "${name1}" if name1 is null. So it looks to me like name1 is null. You might also want to change your #if condition to #if ($name1), which will evaluate to false if name1 is null.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top