예를 들어, 봄 설정에서 나는이 방법 -은 스프링 설정 파일에서 값을 얻는 것은 직접
private String getFruitName(){
/* result should come from config depending on the
value of this.fruit [a fruit type which can be one
of the first four keys in the map.] */
}
이 지금 this-
<util:map id="someMap"
map-class="java.util.HashMap"
key-type="java.lang.String"
value-type="java.lang.String" >
<entry key="A" value="Apple" />
<entry key="B" value="Banana" />
<entry key="C" value="Cherry" />
<entry key="D" value="Durian" />
<entry key="Default" value="None" />
같은지도가 클래스의 메소드에서 키를 주입하여 값을 가져 오는 대신 스프링 구성 파일로 설정된 조건을 사용하여 직접 어떻게 수행합니까? 구성에서 조건문을 사용할 수 있으며 어쩌면 구성에 매개 변수를 전달할 수 있습니까? 당신은 봄이 작업을 수행하지 할
if (someMap.containsKey(fruit)){
fruitName = someMap.get(fruit);
}