ページの先頭行へ戻る
Interstage Business Application Server オープンJavaフレームワークユーザーズガイド
FUJITSU Software

3.1.10 Spring EL

bean定義やアノテーションに#{...}という構文を使用して動的な値を利用できます。

例1は、user.timezoneというシステムプロパティの値を取得する例です。また、例2は、他のbeanの値を取得する例です。例3は、アノテーションを使用した例です。

例1 システムプロパティの値を取得
<bean id="fooSample" class="xxx.FooSampleImpl">
	<property name="timezone" value="#{ systemProperties['user.timezone'] }"/>
</bean>
例2 beanの値を取得
<bean id="fooSample2" class="xxx.fooSample2Impl">
	<property name="randomNumber" value="#{ T(java.lang.Math).random() * 100.0 }"/>
</bean>
<bean id="fooSample3" class="xxx.fooSample3Impl">
	<property name="seed" value="#{ fooSample2.randomNumber }"/>
</bean>
例3 アノテーションを使用
public static class FooSampleImpl{
	@Value("#{ systemProperties['user.timezone'] }")
	private String timezone;
	public void setTimezone (String timezone){
		this.timezone = timezone;
	}
	public String getTimezone (){
		return this.timezone;
	}
}