0

I have a servlet used to create an account. I have a question: to me, the controller should be totally independent of request's parameters, but for example if I have a controller method like

public User signup(String pseudo, String firstname, String lastname, String password, String email)

and i want the user to type his password twice, should I pass the second input as an argument to signup (breaking the "simplicity" of this method) or should I check if the first password matches the second in the servlet (keeping the controller doing only it's job, but making the servlet check inputs) ?

4

1 回答 1

1

Imagine that controller is a glue between your view and model(services, daos, etc.). Controller should parse incoming data from the view, pass it to the model, and then return response.

In your case I would check if passwords are equal at page via JavaScript, send data with only one password to controller(servlet), extract in controller required parameters and invoke method from business logic to create account.

于 2013-06-28T20:49:42.757 回答