I am using Spring MVC and in my controller, I want to be able to automatically bind incoming parameters to my Java object. It seems like this should be pretty easy to do. The only wrinkle is that the incoming parameter names (e.g. "username") may not match up exactly with the field name in the java object (e.g. "name").
From the Spring documentation (http://static.springsource.org/spring/docs/2.5.6/reference/mvc.html):
"Spring Web MVC allows you to use any object as a command or form object.... All this means that you don't need to duplicate your business objects' properties as simple, untyped strings in your form objects just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it is often preferable to bind directly to your business objects. "
How do I actually do this? Any code or links appreciated.
For example, my business object
public class User {
private String username;
private String password;
//getters and setter
}
The request my controller is handling:
example.com/login?name=Steve&pw=1234
I would like to bind "Steve" to User.username and "1234" to User.password.
Thanks.