I tried searching in Google, but I could not find any good examples where a username and password are checked with a database for authentication purposes.
In further
App-fuse will give you a full working example: http://appfuse.org/display/APF/AppFuse+QuickStart
Or if you have maven installed simply run:
mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-light-spring-security-archetype -DarchetypeVersion=2.1.0-M2 -DgroupId=com.mycompany -DartifactId=myproject
This will generate an appfuse light project with spring mvc, spring security and hibernate.