userus1313
userus1313

Reputation: 1

Username from form is always null

I try to create new user using form in register.html (registration process is included in UserController). In String registrationPost, there should be object newUser containing datas from form (username, password, sex, role).

When I use newUser.toString(), it shows everything except username (for example: 'PRINTED newUser: UserForm{username='null', password='mypassword', userSex=MALE, userRole=ADMIN}')

What can I do to get also username from form? Why everything is sent except one field? Please, help me, guuuuys!

Links to project:

Controller: https://github.com/ToTomki/getinpoland/blob/master/src/main/java/pl/getinpoland/controller/UserController.java

Template: https://github.com/ToTomki/getinpoland/blob/master/src/main/resources/templates/user/register.html

Upvotes: 0

Views: 118

Answers (1)

David Lavender
David Lavender

Reputation: 8311

You have a problem in UserForm.java

 public void setUsername(String username) {
     this.username = this.username;
 }

Should be:

 public void setUsername(String username) {
    this.username = username;
 }

Upvotes: 3

Related Questions