Saturday, February 12, 2011

In a spring configuration, what is the difference between using name vs id?

In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribute?

  • Essentially, this is really just a XML matter. But you can also use the name attribute to specify aliases for a bean using characters which would be illegal in an id, I think.

    From cretzel
  • In general, you should try to use id instead of name when you can. That way, the parser can catch duplicates for you.

    From lowellk

0 comments:

Post a Comment