Normally
you should not be passing database connection information into your web application, you should be using a database connection pool. That will not only keep sensitive information outside of the webapp entirely, it will also allow you to use database connections more efficiently.
There are exceptions to that rule. I have a database editor program where instead of a fixed connection pool I select the database that the web application user will be working with as part of the web application logic.
In the case of providing connection credentials to the Spring application context, you can use JNDI in association with the application resources definition in web.xml, which can be overridden by the webapp server-specific deployment descriptor (in
Tomcat, that's the Context).
A Spring JNDI element would look like this:
That particular element then defines a spring bean that can be referenced by (injected into) other Spring objects.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.