2012-01-16 66 views
1

我是Spring Framework的新手。 這是關於使用ref屬性引用另一個bean的。Spring Framework(V2.5) - 在bean定義的ref屬性中使用actionpath

我有一個像下面這樣的動作類的bean定義。

<bean name="/abc" class="com.example.actions.Action" scope="singleton"> 
    <property name="businessLogic" ref="/pqr"/> 
</bean> 

我想使用ref屬性(即「/ pqr」)注入另一個bean到這個bean中。

<bean name="/pqr" class="com.example.businesslogic.PqrBL" scope="prototype" /> 

現在我的問題是如何正常它使用NAME =「/ PQR」樣的符號來一個bean這是不是有些動作類的定義?按照慣例,這是一個可接受的正常情況? PS:請讓我知道,如果提供的信息不完整或問題不明確。

感謝

回答

0

Spring參考指出

The convention is to use the standard Java convention for instance field names when 
naming beans. That is, bean names start with a lowercase letter, and are camel-cased from 
then on. Examples of such names would be (without quotes) 'accountManager', 
'accountService', 'userDao', 'loginController', and so forth. 

這是不正常使用 「/ PQR」 作爲一個bean的名字,但你可以做到這一點。我寧願使用更多用戶友好的名稱來使用bean,而不是使用「路徑」。

檢查here爲約定。

+0

非常感謝您的精確答案:) – Boney 2012-01-16 07:16:36

相關問題