[英]Tomcat error: bean's property cant be found
Tomcat indicates error: Tomcat表示错误:
org.apache.jasper.JasperException: An exception occurred processing JSP page /AccueilEmploye.jsp at line 10
7: <body>
8: <p>
9: Accueil pour:${masession.type }<br>
10: Votre id: ${masession.idemp }<br>
11: Bienvenu<br>
12: ${message}<br>
13: email: ${masession.email }<br>
This is the AccueilEmploye.jsp file. 这是AccueilEmploye.jsp文件。
<body>
<p>
Accueil pour:${masession.type }<br>
Votre id: ${masession.idemp }<br> <%-- ERROR HERE --%>
Bienvenu<br>
${message}<br>
email: ${masession.email }<br>
Mot de passe: ${masession.mdp}<br>
Nom: ${masession.nom}<br>
Prenom: ${masession.prenom }<br>
Departement:${masession.dept }
</p>
</body>
Can't figure out where's the problem, Error says that the property idemp isnt available in the bean, while it is there. 无法弄清楚问题出在哪里,Error说,bean中的属性idemp不可用,而它就在那里。
public class Utilisateur {
private String nom;
private String prenom;
private String email;
private String dept;
private String poste;
private String agence;
private String mdp;
//private int id_emp;
private String type;
private Timestamp date_inscr;
private int idemp;
This is the part of the servlet that sends the object emp to the View ( JSP ) 这是将对象emp发送到View(JSP)的servlet的一部分
else {
msg="";
request.setAttribute("message", msg);
session.setAttribute("masession", emp);
if (emp.getType().equals(Employe)){
VUE="/AccueilEmploye.jsp";
} else if (emp.getType().equals(Technicien)){
VUE="/AccueilTechnicien.jsp";
} else if (emp.getType().equals(TechnicienR)){
VUE="/AccueilTechnicienR.jsp";
} else if (emp.getType().equals(Admin)){
VUE="/AccueilAdmin.jsp";
}
this.getServletContext().getRequestDispatcher(VUE).forward(request, response);
}
I think the problem might be in the getter of the attribute you're trying to access. 我认为问题可能出在您尝试访问的属性的getter中。 The newest jsp
${...}
syntax accesses the attribute throught it's getter. 最新的jsp
${...}
语法通过它的getter访问该属性。 So, if you want to access attribute idemp
in jsp using ${masession.idemp}
, you need to have a getter named getIdemp()
in the respectful class. 所以,如果你想使用
${masession.idemp}
在jsp中访问属性idemp
,你需要在尊重的类中有一个名为getIdemp()
的getter。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.