Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
739 views
in Technique[技术] by (71.8m points)

jsp - Property 'someproperty' not found on type java.lang.String

I am getting this error and I can not figure out where the problem might be. The "userid" column is in the database and is in the bean. Does anyone have any idea?

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 

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The exception is basicaly telling you that ${user} is an ordinary java.lang.String. According to the javadoc, it has indeed no getUserid() method representing an userid property.

Make sure that you're setting a concrete User instance in the desired scope instead of a plain vanilla String. As you haven't shown anywhere in the question how you're preparing the scoped variable, it isn't possible to give a targeted answer on that, but it should at least look something like this:

User user = userService.find(id);
request.setAttribute("user", user); // and thus not e.g. setAttribute("user", "user") or something.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...