[置頂]velocityの中のvelocityCounterが機能しない原因
1949 ワード
今日はorg.springframe ewark.ui.velocity.VelocityEngine FactoryBeanを使う時、velocityCounterという変数の時は死活して機能しません.長い間苦しめてもだめです.ネット上では何の資料も見つけられません.以前は元の生態を使ってspringと統合しない時はまだ大丈夫です.しょうがないです.きちんとソースをダウンロードして見ました.
最後に、元の配置ファイルの原因であることが分かりました.
一部のソースコード
最後に、元の配置ファイルの原因であることが分かりました.
一部のソースコード
RuntimeConstants
/** Counter reference name in #foreach directives. */
String COUNTER_NAME = "directive.foreach.counter.name";
org.apache.velocity.runtime.directive.Foreach
counterName = rsvc.getString(RuntimeConstants.COUNTER_NAME);
counterName = rsvc.getString(RuntimeConstants.COUNTER_NAME);
hasNextName = rsvc.getString(RuntimeConstants.HAS_NEXT_NAME);
counterInitialValue = rsvc.getInt(RuntimeConstants.COUNTER_INITIAL_VALUE);
if (!"velocityCount".equals(counterName))
これは変数名です.私の設定ファイルです.<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="resourceLoaderPath" value="classpath*:template" />
<property name="velocityProperties">
<props>
<prop key="resource.loader">class</prop>
<prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
<prop key="velocimacro.library" />
<prop key="directive.foreach.counter.name">loopCounter</prop>
<prop key="directive.foreach.counter.initial.value">1</prop>
<prop key="file.resource.loader.cache">true</prop>
<prop key="parser.pool.size">50</prop>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
</props>
</property>
</bean>
loopCounterに設定されていますので、loopCounterを使わなければなりません.