Property 'someproperty' not found by type java.lang.String

I am getting this error and I cannot figure out where the problem may be. The "userid" column is in the database and is in the bean. Does anyone have any ideas?

org.apache.jasper.JasperException: An exception occurred processing JSP page /user.jsp at line 24 21: 22: <form method="POST" action="AdminServlet" name="frmAddUser"> 23: User ID : <input type="text" readonly="readonly" name="userid" 24: value="<c:out value="${user.userid}" />" /> Username : <input 25: type="text" name="firstName" 26: value="<c:out value="${user.firstName}" />" /> LastName : <input 27: type="text" name="lastName" root cause javax.el.PropertyNotFoundException: Property 'userid' not found on type java.lang.String 

Thanks.

+4
source share
3 answers

The exception basically tells you that ${user} is regular java.lang.String . According to javadoc , it really does not have a getUserid() method representing the userid property.

Make sure you create a specific instance of User in the required area, and not just plain vanilla String . Since you have not indicated anywhere in the question how you prepare a variable with a scope, it is impossible to give a focused answer to it, but it should look something like this:

 User user = userService.find(id); request.setAttribute("user", user); // and thus not eg setAttribute("user", "user") or something. 
+3
source

One of the following should be, according to me

  • The userid data type does not match the one in the bean. It can be integer in db.

  • The property is not defined in the bean class. The name may be different, and you must conclude that it is userid .

0
source

Are you doing <c:set var="user">${user}</c:set> anywhere in jsp?

According to Answer 1 on another question, JSP performs an implicit conversion to a string when setting var to JSP.

0
source

All Articles