2017-08-24 5 views
1

を動作しない私は、1.7から2.0までの速度を更新$のvelocityCountは動作していないとき、およびエラーました:起こる何

[org.apache.velocity.rendering] - Left side ($velocityCount) of comparison operation has null value 

を?

私のコードは次の通りである:

"images": [ 
     #foreach($image in $cl.images) 
     #if($velocityCount <= 3) 
     #set($img = $cot.encryptUrlForTrans($image.imageUrl)) 
     #set($_img = "http://tf.example.com/tc/img/") 
     #if($velocityCount != 1),#end 
     { 
      "url": "$_img$img?enable=&w=120&h=80&cut=", 
      "width": 120, 
      "height": 80 
     } 
    #end 
    #end 
    ] 

とNullPointerExceptionが持っている#set($img = $cot.encryptUrlForTrans($image.imageUrl))ライン?これが実行可能な場合、$ imageはnullでなくてはなりません、どうしたらエラーが発生するのか分かりません。 encryptUrlForTrans(null)メソッドが正しい戻り値を持つためです。

+0

コードの追加方法を教えてください。 – soorapadman

答えて

0

upgrading instructionsをフォローし、以前のエラーのログを確認する必要があります。

わずか1ベースカウンタのゼロベースのインデックス、または$foreach.countため$foreach.indexを使用し、依存関係を変更しても

To maximize backward compatibility with Velocity 1.x, be sure to include the following lines in your Velocity configuration:

runtime.conversion.handler = none space.gobbling = bc

+0

あなたの答えをありがとう。 $ velocityCountはvelocity2.0では使用できませんか? –

+0

Apache Cayenneをお使いですか?それはvelocity.propertiesに 'directive.foreach.counter.name = velocityCount'を含んでいます – user7294900

0

する必要があります。

もちろん、user7294900が提案するようにupgrading instructionsをチェックしてください。