Skip to content
Advertisement

I getting an error while i am trying to update an user and not able to show my users roles using SpringBoot

what i am trying to do after logging in, in the usersPage, i am trying to show all users with their roles and when i click on edit on one of them i get to edit_user page which i will allow me to edit users but i get an error while am doing that and in the usersPage i can’t see user’s roles.

USER ENTITY:

JavaScript

UserRegistrationDto

JavaScript

}

UserController

in this controller layer it responsible for getting,deleting,editing users

JavaScript

}

UserService

JavaScript

edit_user.html

JavaScript

users.html where i will show all users

JavaScript

Advertisement

Answer

The first error you made is in edit_user.html, as the stack trace you provided says, the endpoint /user/update/{id} is failing to convert ‘{id}’ to a long. That’s because id you are passing is not the user id but the string ‘{id}’ itself.

in edit_user.html change this:

JavaScript

to

JavaScript

if this still not work I suggest passing userID as an attribute in the model too.

For the second problem, you can’t visualise users roles because of this line in users.html:

JavaScript

since User.roles is a collection, it can’t be rendered at “once”, you have to use the same syntax used in edit_user, hence:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement