2012-01-16 64 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

相关问题