java - Optimal way to construct an instance from an http request parameters -


in project have:

  1. a servlet handles http requests users profile info parameters, i.e (username = "bob" , password = "ugabaga", address = "blabla"... )

  2. a user class represents user info. getters + setters : getname(), setname(string username)....

my question , there easy way create new user instance httprequest parameters?

something :

user newuser = createuserfromparams (new user(), httprequestparameters);

(without need write : user.setname(parameters.getparameter("username")) each of 30~ fields)

p.s - i'm not sending password, couldn't think of fieldname. passwords being sent sms's ;)

thanks in advance!

there httpservletrequest.getparametermap, delivers map<string, string[]> have `?a=1&a=2'. beanutils not do.

but can make own utility class using java reflection, or translate request parameters map<string, string> , use standard bean utility (apache).


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -