我有这个例外而且我找不到解决方案
COntroller:
@RequestMapping(value="/sujet")
public String detail(Model model, HttpServletRequest request, Long idSujet) {
Utilisateur user = (Utilisateur) request.getSession().getAttribute("user");
model.addAttribute("nbrMails", metierUtilisateur.listDesEmailsRecuNonLu(user.getIdUtilisateur()).size());
SujetForum sujet = metierSujetForum.findById(idSujet);
sujet.setMessagesForums(metierSujetForum.getListMessageForum(idSujet));
model.addAttribute("sujet", sujet);
model.addAttribute("messages", metierSujetForum.getListMessageForum(idSujet));
return "/coordinateur/detailSujetForum";
}
这是我的Bean定义: 我为所有属性定义了所有getter和setter,但直到获得相同的异常
@Entity
public class MessagesForum implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idMessage;
private String message;
private Date dateDepotMessage;
private boolean messageCorrecte;
@ManyToOne
@JoinColumn(name = "idSujet")
private SujetForum sujetForum;
@ManyToOne
@JoinColumn(name = "idUtilisateur")
private Utilisateur utilisateur;
@OneToMany(mappedBy = "messageForum")
private Collection<PieceJointeForum> pieceJointeForums;
public MessagesForum(String message, Date dateDepotMessage, boolean messageCorrecte) {
super();
this.message = message;
this.dateDepotMessage = dateDepotMessage;
this.messageCorrecte = messageCorrecte;
}
public MessagesForum() {
super();
}
public Long getIdMessage() {
return idMessage;
}
public void setIdMessage(Long idMessage) {
this.idMessage = idMessage;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Date getDateDepotMessage() {
return dateDepotMessage;
}
public void setDateDepotMessage(Date dateDepotMessage) {
this.dateDepotMessage = dateDepotMessage;
}
public boolean isMessageCorrecte() {
return messageCorrecte;
}
public void setMessageCorrecte(boolean messageCorrecte) {
this.messageCorrecte = messageCorrecte;
}
public SujetForum getSujetForum() {
return sujetForum;
}
public void setSujetForum(SujetForum sujetForum) {
this.sujetForum = sujetForum;
}
public Utilisateur getUtilisateur() {
return utilisateur;
}
public void setUtilisateur(Utilisateur utilisateur) {
this.utilisateur = utilisateur;
}
public Collection<PieceJointeForum> getPieceJointeForums() {
return pieceJointeForums;
}
public void setPieceJointeForums(Collection<PieceJointeForum> pieceJointeForums) {
this.pieceJointeForums = pieceJointeForums;
}
}
这是异常的输出
615: <div class="media-body">
616: <div class="media-text">
617: <h5 class="semibold mt0 mb5 text-accent"></h5>
618: <p class="mb5">${msg.getIdMessage() }.</p>
619: <!-- meta icon -->
620: <p class="mb0">
621: <span class="media-meta"></span> <span class="mr5 ml5 text-muted">*</span> <a href="javascript:void(0);" class="media-meta text-default" data-t
oggle="tooltip" title="" data-original-title="Reply"><i class="ico-reply"></i></a>
Stacktrace:] with root cause
javax.el.MethodNotFoundException: Method not found: class java.lang.String.getIdMessage()
at javax.el.Util.findWrapper(Util.java:352)
at javax.el.Util.findMethod(Util.java:214)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:174)
at org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:139)
at org.apache.el.parser.AstValue.getValue(AstValue.java:173)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:967)
at org.apache.jsp.WEB_002dINF.views.coordinateur.detailSujetForum_jsp._jspx_meth_c_005fforEach_005f0(detailSujetForum_jsp.java:1242)
at org.apache.jsp.WEB_002dINF.views.coordinateur.detailSujetForum_jsp._jspService(detailSujetForum_jsp.java:832)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
答案 0 :(得分:1)
<c:forEach items="=${messages }" var="msg">
<div class="media-list media-list-bubble">
<div class="media">
<a href="javascript:void(0);" class="media-object pull-left"> <img src="" class="img-circle" alt="">
</a>
<div class="media-body">
<div class="media-text">
<h5 class="semibold mt0 mb5 text-accent"></h5>
<p class="mb5">${msg.idMessage }.</p>
<!-- meta icon -->
<p class="mb0">
<span class="media-meta"></span> <span class="mr5 ml5 text-muted">*</span> <a href="javascript:void(0);" class="media-meta text-default" data-toggle="tooltip" title="" data-original-title="Reply"><i class="ico-reply"></i></a>
</p>
<!--/ meta icon -->
</div>
</div>
</div>
</div>
</c:forEach>
答案 1 :(得分:0)
msg 似乎是以String形式出现的,你期待你的bean类类型。
你得到豆之后
$ {msg.getIdMessage()}。
这似乎是你的JSP中的问题。试试
${msg.idMessage() }.
答案 2 :(得分:0)
向我发送你的jsp,不要用get方法调用你应该直接用属性值调用。像amit.rk3说的那样。以及在jsp中使用此msg的位置 像这样使用
<c:forEach var="msg" items="${messages}">