The main reason to write this article is: Because, today's group of a small partner asked a question, and then we guessed for a long time, the data has problems, attributes have problems and so on. Finally found is a small error caused by the Internet, and looked up the relevant data found that we are in the group did not guess right of those problems. So I decided to record it.
Console output:
Javax.el.PropertyNotFoundException:Property ' name ' not found on type java.lang.String
Page output:
Org.apache.jasper.JasperException:An exception occurred processing JSP page/web-inf/jsp/user/findall.jsp at line 30
This mistake believe that everyone in the write El expression when all met, and on the data problem, attribute problems and so on I do not write, on the record of today's group of small partners to ask questions
Entity classes:
public class Users {
private Long ID;
private String name;
Private String pwd;
Public Long GetId () {return
ID;
}
public void SetId (Long id) {
this.id = ID;
}
Public String GetName () {return
name;
}
public void SetName (String name) {
this.name = name;
}
Public String getpwd () {return
pwd;
}
public void SetPwd (String pwd) {
this.pwd = pwd;
}
}
Action class:
@RequestMapping (value = "/find.do", method=requestmethod.get) public
Modelandview FindAll () {
list< users> FindAll = Usersservice.findall ();
Modelandview mv = new Modelandview ();
Mv.addobject ("list", FindAll);
Mv.setviewname ("User/findall");
return MV;
}
JSP page:
<c:foreach items= "list" var= "C" >
<tr>
<td>${c.name}</td>
<td>${ C.pwd}</td>
</tr>
</c:forEach>
See here, have you found any problems?
The correct JSP page:
<c:foreach items= "${list}" var= "C" >
<tr>
<td>${c.name}</td>-<td>${
C.pwd}</td>
</tr>
</c:forEach>
Believe this problem many people will choose sex skip. So the last group of small partners are ashamed of.
If you haven't found the problem yet ... Items=${list}