Skip to content
Advertisement

Property or field ‘id’ cannot be found on object of type ‘java.lang.Boolean’ – maybe not public or not valid?

I am writing a SpringBoot application for an e-commerce website project where I’m creating a form to change the current password of the user account. I am getting the following two errors when the form gets submitted.

  1. ERROR-1
JavaScript
  1. ERROR-2
JavaScript

HomeController

JavaScript

myprofile.html

JavaScript

User Class

JavaScript

User Service

JavaScript

User Service Implementation

JavaScript

}

Advertisement

Answer

Here you try to access the id field of the user model attribute:

JavaScript

Here you set the user model attribute to true, therefore it’s of type boolean:

JavaScript

As a variable of type boolean does not have a field called id, trying to access it gives the error you see. I assume what’s going on is that you didn’t want to set that model attribute to true (perhaps you wanted to set it to currentUser?), or that the id field that you want to access belongs to another model attribute.

Advertisement