Is there any difference between using an id
attribute and name
attribute on a
element in a Spring configuration file?
Either one would work. It depends on your needs:
If your bean identifier contains special character(s) for example (/viewSummary.html
), it wont be allowed as the bean id
, because it's not a valid XML ID. In such cases you could skip defining the bean id
and supply the bean name
instead.
The name
attribute also helps in defining alias
es for your bean, since it allows specifying multiple identifiers for a given bean.